Values and objects
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Sun May 11 08:51:08 EDT 2014
On Sun, 11 May 2014 11:26:41 +0300, Jussi Piitulainen wrote:
> 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.
I'm not sure if you are agreeing or disagreeing that variables are values
in Common Lisp or not. First you say they are, they you say "maybe not".
The point is, it is *logically impossible* for a language to use
precisely the same syntax for value-assignment and variable-assignment.
Consider the variable called "x", which is bound to the value 23. If the
language has a single assignment operator or statement:
let y := name;
that cannot be used for *both* binding the value 23 to y and binding the
variable "x" to y (making y an alias for x).
To use Pascal as an example, you cannot use the same declaration for pass-
by-value and pass-by-reference, one or the other must use different
syntax.
function foo(x: integer, var y: integer): integer;
Given that declaration, and the function call foo(a, b), x is bound to
the value of a, while y is bound to the variable b.
In the case of Common List, I count at least four different assignment
forms:
set, setq, setf, psetq, let
plus two unbinding forms:
makunbound, fmakunbound
but I don't know enough about Lisp to tell you which ones implement
binding-to-values and which binding-to-variables, if any.
--
Steven D'Aprano
http://import-that.dreamwidth.org/
More information about the Python-list
mailing list