Values and objects

Marko Rauhamaa marko at pacujo.net
Sun May 11 11:10:16 EDT 2014


Rustom Mody <rustompmody at gmail.com>:

> On Sunday, May 11, 2014 11:51:59 AM UTC+5:30, Marko Rauhamaa wrote:
>> Lisp variables (symbols) are on an equal footing with other objects.
>> IOW, lisp variables are objects in the heap.
>
> But is a symbol a variable??

Yes. A classic lisp symbol is even more "variable" than most other
variables! It can hold *two* values. One is called a value binding and
the other one the function binding. Scheme has unified the two; scheme
symbols have only one value binding, which can be a function.

> Sure, by providing a data-structure symbol, lisp provides one of the
> key building blocks for developing language processing systems.
>
> However I would argue that a variable is not a merely a symbol
> (identifier in more usual programming language-speak) but a relation
> between identifiers/symbols and some 'rhs'

The lisp symbol really is a data object with several fields: I can think
of name, value, function and properties. They can be accessed with
accessor functions. (Interestingly, scheme doesn't have the
'symbol-value accessor function of lisp's.)

If lisp didn't have a way to rebind symbols (i.e., if it were purely
functional and had no side effects), they wouldn't be so much variables
as substitution spots in the code.

> For an (interpreted?) language like python, rhs is naturally
> value/object For a C like language it is memory.

Symbols in lisp are memory slots, conceptually and physically.


Marko



More information about the Python-list mailing list