[Python-ideas] Syntax for late-binding of arguments [was: Default arguments ...]

Nick Coghlan ncoghlan at gmail.com
Fri May 15 12:26:30 CEST 2009


Steven D'Aprano wrote:
> Some years ago, Python overloaded the binary operators * and ** for use 
> as special markers in parameter lists. I suggest we could do the same, 
> by overloading the & operator in a similar fashion: inside the 
> parameter list, &x would mean to delay evaluation of the default 
> argument:

Yikes, that syntax would seriously confuse any C++ programmer (me
included). I wouldn't be able to avoid thinking of those parameters as
pass by reference (i.e. actually referring to the memory location of the
passed in argument so you can fiddle with immutable values in the
caller, not just pass-a-reference-by-value the way Python does for
normal arguments).

Marking the parameter name strikes me as wrong anyway - it's only the
evaluation of the default argument which is special, not the parameter
itself.

Cheers,
Nick.

P.S. (The subject line change caught my attention. The recap of the
discussion was very handy, and it does appear to have evolved in a more
useful direction, but I'm going back to largely ignoring the thread now...)

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------



More information about the Python-ideas mailing list