3 ms·
A binding being an association between a name and a value is a defect in Common Lisp. The correct view (in a language with mutable variables) is that it's an a
by kazinator 3y ago
A binding being an association between a name and a value is a defect in Common Lisp.
The correct view (in a language with mutable variables) is that it's an association between a name and an abstract location where a value is stored. When we assign to a variable, the binding doesn't change; any closure which has captured that binding sees the new value.
On entry into a lexical scope, fresh bindings are allocated only once, no matter how many times a new value is assigned to any of them in that same scope.
Schemers get this right. In R7RS:
An identifier that names a location is called a variable and is said to be bound to that location.
The problem is not just in the Glossary. defvar is documented as leaving the variable unbound if it is previously unbound (in the case when no initial-value is specified).
Yet, defvar is described as establishing the name as a dynamic variable. But a variable is defined as a binding. Thus if X is unbound and (defvar X) leaves it unbound, then it is not establishing a variable because that would require a binding. Oops!
- lisper 3y ago> A binding being an association between a name and a value is a defect in Common Lisp. Well, it would be if that is how CL actually defined the word "binding" but it's not. The CL glossary defines "binding" simply as "an association between a name and that which the name denotes". It does not specify that "that which the name denotes" must be a value, and in fact there are name spaces (collections of bindings) in CL where the things denoted by names are not values. The TAG namespace, for example. The CL authors did make a few mistakes, but the definition of "binding" is not one of them.
- kazinator 3y agoSorry, I blundered. What I wanted is that a variable is defined as a binding between a name and value.