Finn Mason writes:

 > Is its not being done before really a good argument against it?

No, but that's not the whole of the argument being made.  The implied
argument is that having two different ways to evaluate defaults is
complexity that arguably isn't needed: either because late binding is
a YAGNI in view of the perfectly usable if not usably perfect
arg=sentinel idiom, or because it's expected to be subsumed by a more
general deferred evaluation scheme.  Then "not done before" means we
have no experience to help judge whether the benefits of having *both*
are worth the costs of having *both*.

 > It may be that there simply hasn't been a need in the other
 > languages.

In Lisp, that's true: you just quote the expression in the usual way
to turn a funcall into an object.[1]  I don't know about the other
languages.

 > Also, on a kind of side note, what would be a situation where early binding
 > is advantageous to late binding?

Besides performance, as Steven d'A mentions, there is the case of a
mutable default that should be static (the same object used in all
calls to that function).


Footnotes: 
[1]  CLtL2 is explicit that a Sufficiently Smart Compiler is allowed
to optimize the code of the function if it can determine that the
default expression will resolve to a constant.  It's not clear to me
that that is ever possible in Lisp, for the same reasons it's quite
difficult in Python.

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/FKXSMWLLHJVQ6DXFJBHHTJI62FP7IMBO/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to