Late-binding of function defaults (was Re: What is a function parameter =[] for?)

Jussi Piitulainen harvesting at is.invalid
Fri Nov 20 03:49:21 EST 2015


dieter writes:
> Chris Angelico writes:
>
>> IMO it's controversial mainly because there's an easy and obvious
>> syntax for early binding, but late binding doesn't have syntactic
>> support, and all the options are imperfect.
>
> I do not think that we should get additional syntax for lately bound
> default values. It would explicitely introduce the concepts early
> versus late binding which are likely difficult to understand by many
> users.

I'm confused by the term. I don't like it one bit.

"Early binding" of a default value seems to mean that the expression
that produces the default value of a function parameter is evaluated
when the function is defined. "Late binding" seems to mean that the
expression is evaluated when the function is called.

In both cases the actual binding of the parameter to the value (either
the default or an actual argument) is established when the function is
called. Several different bindings of that same parameter to different
values can hold simultaneously, so the *binding* has to be conceptually
"late". Because recursion.

Why isn't the evaluation of the default expression called evaluation?
Or at least something that doesn't already mean something else that is
as crucially important as, well, I've already given up on talking about
REDACTED and REDACTED in connection with Python, and here I see related
established terminology used for something else *for no reason that I
can see*.

I see no *need* to call this other thing "binding".



More information about the Python-list mailing list