Values and objects

Jussi Piitulainen jpiitula at ling.helsinki.fi
Sun May 11 04:26:41 EDT 2014


Marko Rauhamaa writes:
> Rustom Mody:
> 
> > On Saturday, May 10, 2014 2:39:31 PM UTC+5:30, Steven D'Aprano wrote:
> >> 
> >> Personally, I don't imagine that there ever could be a language
> >> where variables were first class values *exactly* the same as
> >> ints, strings, floats etc.
> >
> > [...]
> >
> > What you mean by *exactly* the same mean, I am not sure...
> 
> Lisp variables (symbols) are on an equal footing with other objects.
> IOW, lisp variables are objects in the heap.

Only some, or only in quite old or special members of the family. But
yes, I suppose when Lisp was still LISP, it was the kind of language
that Steven fails to imagine in the quotation above. Variables really
were symbols, which still are objects that can be passed around and
stored in data structures. Or maybe not - wasn't the essential binding
component (originally an "association list", later a more abstract
"environment", called "namespace" in Python culture) separate from the
symbol even then? Global bindings aside.

But default in Common Lisp is lexical binding, and Scheme has only
lexical bindings. An ordinary lexical variable is not an object in any
reasonable sense that I can see.

(let ((f (let ((x 3)) (lambda () x))))
   ;; The binding of x is still relevant here but not in scope and not
   ;; accessible through the symbol x
   (funcall f)) ;==> 3

# That's (lambda f : f())((lambda x : (lambda : x))(3)) #=> 3
# Roughly, f = (lambda x : (lambda : x))(3) ; f()       #=> 3



More information about the Python-list mailing list