Dynamic methods and lambda functions

Steve Holden steve at holdenweb.com
Tue Jan 27 02:39:49 CET 2009


Mark Wooding wrote:
> Steve Holden <steve at holdenweb.com> writes:
> 
>> Mark Wooding wrote:
>>>   * Assignment stores a new (reference to a) value in the variable.
>>>
>>>   * Binding modifies the mapping between names and variables.
>>>
>> I realise I have omitted what was doubtless intended to be explanatory
>> detail, but I am having trouble reconciling those sentences. Would you
>> mind explaining "in vacuuo" what you see as the difference between
>> assignment and binding?
> 
> OK.  This turned into something of an essay.  I hope that it's of use to
> somebody...
> 
> A name is a kind of expression.  Expressions can be evaluated to yield
> values.  Therefore, a name can be evaluated to yield a value.  How does
> this happen?  There are two distinct mappings involved.
> 
> The first mapping is from names to variables.  This mapping is usually
> called the `environment', and is acted upon by `binding'.  The extent of
> the program text whose meaning is affected by a binding is called the
> `scope' of the binding[1].  In Python, the scope can be determined
> statically by analysing the program text (`lexical scope').  In some
> languages the scope can only be determined at run time (`dynamic
> scope'); other languages have a mixture of the two.
> 
Yes. Kay Schleur pointed out that my confusion was due to too close a
mental proximity to the Python term "binding value to names" for
assignment. Once I realised you were using "binding"to refer to the
scope of names it all made much more sense.

[...]
> 
> Chapter 3 of the Structure and Interpretation of Computer Programs, by
> Abelson and Sussman explains this stuff in a more discursive and
> approachable manner.  If you're still confused by my explanation (and by
> nature I tend to err on the side of precision rather than clarity, a
> fault which I know impairs my teaching ability), you may find theirs
> more useful:
> 
>  http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-19.html#%_chap_3
> 
> Nonetheless, I hope that this description has been of some use.
> 
I found your precision most helpful, and the entire post was readable
and useful. Thanks.

regards
 Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/




More information about the Python-list mailing list