Empty list as default parameter

Paul Rubin http
Sun Nov 23 20:21:23 EST 2003


bokr at oz.net (Bengt Richter) writes:
> >Common Lisp is the most obvious one.

> You are referring to initforms, I assume. I wonder how often macros
> are used IRL to defeat the deferral and plug in pre-computed static
> default values that the compiler can't infer its way to at compile time?

I can't think of any times I ever did that, but I've never been a real
hardcore CL hacker.

> But the trouble is that the compiler can't guess what you _mean_,
> except for the obvious cases of bare names and constant literals, so
> otherwise you have to code explicitly in any case. E.g., is it
> obvious that getattr(os, 'RD_ONLY') should be done at call time or
> optimized away to def time in os.open('foo.txt', os.RD_ONLY) ?  I
> don't think you can optimize it away without telling the compiler
> one way or another, or changing the dynamic nature of the language.

I think some of that dynamicness should be toned down as Python matures.

> In any case it would be a semantic change, and I'd hate to have the
> job of finding breakage ;-)

Better to do it sooner then, so that there's less stuff to break ;-).




More information about the Python-list mailing list