Re: lambda-returning defmacro, capture



Pascal Bourguignon <pjb@xxxxxxxxxxxxxxxxx> wrote:
Well, right, but (setf (symbol-value 'sym) val) and (symbol-value 'sym)
seem to be defined independently of the different kind of variable.

So you're right that using sym to access (symbol-value 'sym) in the
case of a non dynamic variable is not specified, but we can use
symbol-value.

But why in the world would anyone do that, if the goal is to get
"global lexicals"? There's a good and simple way to accomplish that,
by using symbol-macros.

By the way, I don't find a clear specification that SYMBOL-VALUE
should access the value of dynamic variables... There's some weak
correlation of the two thru boundp, but that's all I can find.

See the description of the SYMBOL class:

Value

If a symbol has a value attribute, it is said to be bound, and
that fact can be detected by the function boundp. The object
contained in the value cell of a bound symbol is the value of the
global variable named by that symbol, and can be accessed by the
function symbol-value. A symbol can be made to be unbound by the
function makunbound.

[...]

Operations on a symbol's value cell and function cell are sometimes
described in terms of their effect on the symbol itself, but the
user should keep in mind that there is an intimate relationship
between the contents of those cells and the global variable or
global function definition, respectively.

--
Juho Snellman
.



Relevant Pages

  • Re: delete command weirdness
    ... another function *with the exact same behavior* and no side effects. ... it does a lot more CONSing while building that return value. ... can modify the place defined by sym in both the case ... a special variable (the value cell of the symbol sym). ...
    (comp.lang.lisp)
  • Re: Stylistic question on control transfer (return vs. throw)
    ... begin a "scope" and retain the location. ... can be handled through property lists. ... (dolist (sym list-of-syms) ... (loop for cell = list-of-syms then (cdr cell) ...
    (comp.lang.lisp)
  • Re: lambda-returning defmacro, capture
    ... So you're right that using sym to access in the ... And global variables are either dynamic variables or ... Operations on a symbol's value cell and function cell are sometimes ... So evaluating sym in the global environment accesses the dynamic ...
    (comp.lang.lisp)
  • Re: Conversion to double from sym is not possible
    ... Steven Lord wrote: ... tempL = UC; %we will be working on one cell at the time ... Conversion to double from sym is not possible. ...
    (comp.soft-sys.matlab)