A critic of Guido's blog on Python's lambda

Ken Tilton kentilton at gmail.com
Fri May 12 20:12:45 EDT 2006



Paul Rubin wrote:
> Alexander Schmolck <a.schmolck at gmail.com> writes:
> 
>>>    (defvar *x*) ;; makes it special
>>>    (setf *x* 1)
>>>    (print *x*) ;;-> 1
>>>    (let ((*x* 2))
>>>       (print *x*)) ;; -> 2
>>>    (print *x*) ;; -> 1
>>
>>You seem to think that conflating special variable binding and lexical
>>variable binding is a feature and not a bug. What's your rationale?
> 
> 
> I thought special variables meant dynamic binding, i.e.
> 
>    (defvar *x* 1)
>    (defun f ()
>        (print *x*)              ;; -> 2 
>        (let ((*x* 3))
>            (g)))
>    (defun g ()
>        (print *x*))             ;; - > 3 
> 
> That was normal behavior in most Lisps before Scheme popularlized
> lexical binding.  IMO it was mostly an implementation convenience hack
> since it was implemented with a very efficient shallow binding cell.
> That Common Lisp adapted Scheme's lexical bindings was considered a
> big sign of CL's couthness.  So I'm a little confused about what Ken
> Tilton is getting at.

Paul, there is no conflict between your example and mine, but I can see 
why you think mine does not demonstrate dynamic binding: I did not 
demonstrate the binding applying across a function call.

What might be even more entertaining would be a nested dynamic binding 
with the same function called at different levels and before and after 
each binding.

I just had the sense that this chat was between folks who fully grokked 
special vars. Sorr if I threw you a curve.

kenny



More information about the Python-list mailing list