[Python-ideas] A bind protocol (was Re: New __reference__ hook)

Terry Reedy tjreedy at udel.edu
Thu Dec 6 06:27:33 CET 2012


On 12/5/2012 3:40 PM, Eric Snow wrote:
> (from the "Re: New __reference__ hook" thread)
>
> On Wed, Dec 5, 2012 at 11:54 AM, Bruce Leban <bruce at leapyear.org> wrote:
>> There is another way to write expressions that don't get evaluated:
>>
>> lambda: a*x + b*y + c
>>
>>
>> So you could write this as z.bind(lambda: rhs) or if this is important
>> enough there could be a new bind operator:
>>
>> lhs @= rhs
>>
>>
>> which is equivalent to
>>
>> lhs.__bind__(lambda: rhs)

This makes no sense to me. The targets of bind statements are not Python 
objects and do not have methods. They may be 'slots' in a python objects 
or may be turned into Python objects (strings), but within functions, 
they are not. In CPython, function local names are turned into C ints or 
uints.

> The lazy/lambda part aside, such an operator would somewhat help with
> performance concerns and allow the "binder" to control when the
> "bindee" gets notified.

So this does not make much sense either.

-- 
Terry Jan Reedy




More information about the Python-ideas mailing list