From: Dan Bensen
Subject: symbol-value returns lexical value?
Date: 
Message-ID: <f0m613$qed$1@wildfire.prairienet.org>
 From the hyperspec:

http://www.lisp.org/HyperSpec/Body/mac_defparametercm_defvar.html#defvar
 > defparameter and defvar establish name as a dynamic variable.

http://www.lisp.org/HyperSpec/Body/acc_symbol-value.html#symbol-value
 > symbol-value cannot access the value of a lexical variable.

What's going on here?  I thought this wasn't supposed to happen:

sbcl 1.0.3:

* (defvar x 1)
X
* x
1
* (let ((x 2)) (symbol-value 'x))
2

-- 
Dan
www.prairienet.org/~dsb/

From: Zach Beane
Subject: Re: symbol-value returns lexical value?
Date: 
Message-ID: <m33b2pb9hk.fsf@unnamed.xach.com>
Dan Bensen <··········@cyberspace.net> writes:

>  From the hyperspec:
> 
> http://www.lisp.org/HyperSpec/Body/mac_defparametercm_defvar.html#defvar
>  > defparameter and defvar establish name as a dynamic variable.
> 
> http://www.lisp.org/HyperSpec/Body/acc_symbol-value.html#symbol-value
>  > symbol-value cannot access the value of a lexical variable.
> 
> What's going on here?  I thought this wasn't supposed to happen:
> 
> sbcl 1.0.3:
> 
> * (defvar x 1)
> X
> * x
> 1
> * (let ((x 2)) (symbol-value 'x))
> 2

In this example, X is a global special variable, not a lexical
variable.

Zach
From: Kent M Pitman
Subject: Re: symbol-value returns lexical value?
Date: 
Message-ID: <uhcr5b8bx.fsf@nhplace.com>
Zach Beane <····@xach.com> writes:

> Dan Bensen <··········@cyberspace.net> writes:
> 
> >  From the hyperspec:
> > 
> > http://www.lisp.org/HyperSpec/Body/mac_defparametercm_defvar.html#defvar
> >  > defparameter and defvar establish name as a dynamic variable.
> > 
> > http://www.lisp.org/HyperSpec/Body/acc_symbol-value.html#symbol-value
> >  > symbol-value cannot access the value of a lexical variable.
> > 
> > What's going on here?  

Short answer: You don't have lexical variables involved.

> > I thought this wasn't supposed to happen:
> > 
> > sbcl 1.0.3:
> > 
> > * (defvar x 1)
> > X
> > * x
> > 1
> > * (let ((x 2)) (symbol-value 'x))
> > 2
> 
> In this example, X is a global special variable, not a lexical
> variable.

To clarify, things defined by DEFVAR and DEFPARAMETER are proclaimed 
SPECIAL.  Unlike a local SPECIAL dclaration, global declarations are
pervasive--that is, they affect new bindings.  So it's as if you had
written
 (let ((x 2)) (declare (special x)) (symbol-value 'x))
Most declarations do not have this effect; binding a variable usually
shadows outer declarations about the variable. e.g., in
 (let ((sym 3)) (declare (special sym)) (let ((sym 4)) (symbol-value 'sym)))
 => 3
This might be a confusing design, but it was at one time essential for
backward compatibility with very large bodies of code.

It is for this reason that, while the language does not require it,
you should _strongly_ consider always naming your special variables
with the *...* naming convention, so that you don't accidentally
bind a variable that you thought wasn't special.  In fact, some
CL compilers will helpfully complain if you do 
  (let ((*foo* 3)) ...)
but have forgotten to do a special proclamation for *FOO* [usually
indirectly through DEFVAR or DEFPARAMETER].

I tried to get global lexicals into the language, but the attempt failed.
See info on failed X3J13 issue PROCLAIM-LEXICAL at 
http://www.nhplace.com/kent/CL/Issues/proclaim-lexical.html
There's no provision for it in the language, but it's an easy user program
to write.  DEFINE-SYMBOL-MACRO is the operator you need, and you can google
for prior discussion on how to set it up.  I'm sure it's there.

Good luck.
From: Dan Bensen
Subject: Re: symbol-value returns lexical value?
Date: 
Message-ID: <f0mdiu$t93$1@wildfire.prairienet.org>
Kent Pitman wrote:
 > things defined by DEFVAR and DEFPARAMETER are proclaimed SPECIAL.

I think my question is specifically, and very pedantically,
about the definition of these "things".
In particular, I'm trying to understand the words "variable"
and "binding", and figure out whether they refer to individual
data structures or to relationships between data structures.

 > Unlike a local SPECIAL declaration, global declarations are
 > pervasive--that is, they affect new bindings.
Okay, that explains the results I got at a practical level.

 > binding a variable usually shadows outer declarations
 > about the variable.

 From the hyperspec:
 > variable n. a binding in the ``variable'' namespace.
 > let and let* create new variable bindings
 > binding n. an association between a name and
 >   that which the name denotes.
 > name n., v.t. 1. n. an identifier by which an object, a binding,
 >   or an exit point is referred to by association using a binding.

Here are the data structures that I'm aware of,
that are relevant to associating names with values:
* The word, i.e. character string, that identifies something
   in source code.
* A hashtable entry that associates the string with
   a pointer or data value.
* A symbol, which is an object that contains an uppercased copy
   of the string, and a pointer for each namespace.
* A chunk of memory that holds the data, i.e. value, that
   everything else ultimately points to.

There are several things here that I find confusing:

HS> variable n. a binding in the ``variable'' namespace.
HS> let and let* create new variable bindings
KP> binding a variable usually shadows outer declarations
     about the variable.

I'm having a lot of trouble finding two precise definitions that
are consistent with all of these statements.  For instance, if
a variable is a binding, per the glossary entry for "variable",
then "binding a variable" sounds like it means "binding a binding",
which doesn't seem to explain much.

HS> name n., v.t. 1. n. an identifier by which an object, a binding,
HS> or an exit point is referred to by association using a binding.

What does it mean to "refer to a binding"?
Is a binding itself an actual data structure?
I thought the word "variable" referred to one of the data structures
I listed above, and a binding was a relationship between those data
structures, where one of them points to another one.

Sorry if I'm being dense here, but this stuff just hasn't
clicked for me yet.

-- 
Dan
www.prairienet.org/~dsb/
From: Ken Tilton
Subject: Re: symbol-value returns lexical value?
Date: 
Message-ID: <q2zXh.39$KT.33@newsfe12.lga>
Dan Bensen wrote:
> Kent Pitman wrote:
>  > things defined by DEFVAR and DEFPARAMETER are proclaimed SPECIAL.
> 
> I think my question is specifically, and very pedantically,
> about the definition of these "things".
> In particular, I'm trying to understand the words "variable"
> and "binding", and figure out whether they refer to individual
> data structures or to relationships between data structures.
> 
>  > Unlike a local SPECIAL declaration, global declarations are
>  > pervasive--that is, they affect new bindings.
> Okay, that explains the results I got at a practical level.
> 
>  > binding a variable usually shadows outer declarations
>  > about the variable.
> 
>  From the hyperspec:
>  > variable n. a binding in the ``variable'' namespace.
>  > let and let* create new variable bindings
>  > binding n. an association between a name and
>  >   that which the name denotes.
>  > name n., v.t. 1. n. an identifier by which an object, a binding,
>  >   or an exit point is referred to by association using a binding.
> 
> Here are the data structures that I'm aware of,
> that are relevant to associating names with values:
> * The word, i.e. character string, that identifies something
>   in source code.
> * A hashtable entry that associates the string with
>   a pointer or data value.
> * A symbol, which is an object that contains an uppercased copy
>   of the string, and a pointer for each namespace.
> * A chunk of memory that holds the data, i.e. value, that
>   everything else ultimately points to.
> 
> There are several things here that I find confusing:
> 
> HS> variable n. a binding in the ``variable'' namespace.
> HS> let and let* create new variable bindings
> KP> binding a variable usually shadows outer declarations
>     about the variable.
> 
> I'm having a lot of trouble finding two precise definitions that
> are consistent with all of these statements.  For instance, if
> a variable is a binding, per the glossary entry for "variable",
> then "binding a variable" sounds like it means "binding a binding",
> which doesn't seem to explain much.
> 
> HS> name n., v.t. 1. n. an identifier by which an object, a binding,
> HS> or an exit point is referred to by association using a binding.
> 
> What does it mean to "refer to a binding"?
> Is a binding itself an actual data structure?
> I thought the word "variable" referred to one of the data structures
> I listed above, and a binding was a relationship between those data
> structures, where one of them points to another one.
> 
> Sorry if I'm being dense here, but this stuff just hasn't
> clicked for me yet.
> 

Have you made it to this part of the CLHS?:

"3.8.26 special Declaration

Syntax:
(special {var}*)

Arguments:
var - a symbol.

Valid Context:
declaration or proclamation

Binding Types Affected:
variable

Description:
Specifies that all of the vars named are dynamic. This specifier affects 
variable bindings and affects references. All variable bindings affected 
are made to be dynamic bindings, and affected variable references refer 
to the current dynamic binding. For example: "

I got here from the DEFVAR description, which might also be useful. I 
think you understand as much as you have read, you just have to read 
more. The CLHS is like that. :)

hth, kt

-- 
http://www.theoryyalgebra.com/

"Algebra is the metaphysics of arithmetic." - John Ray

"As long as algebra is taught in school,
there will be prayer in school." - Cokie Roberts

"Stand firm in your refusal to remain conscious during algebra."
    - Fran Lebowitz

"I'm an algebra liar. I figure two good lies make a positive."
    - Tim Allen
From: Dan Bensen
Subject: Re: symbol-value returns lexical value?
Date: 
Message-ID: <f0mng9$1pt$1@wildfire.prairienet.org>
What triggered my question in this thread is a section
in David Touretzky's "Gentle Introduction"
http://www.cs.cmu.edu/~dst/LispBook/index.html
Page 168--70 in the pdf, 156--8 in the book:
 > (setf a 100)
 > (defun f (a) (list a (g (+ a 1))))
 > (defun g (b) (list a b))
 > In this example, we create a global variable named A with value 100.
 > When we call F, it creates a local variable named A, with value 3,
 > Symbols are never bound; only variables can be bound.
 > And there is no unique variable named A; there are two.
 > Even while F's local variable A is in existence,
 > the global A can be referenced by functions such as G

When I made my list of data structures, I guess I left out pointers,
i.e. lexical bindings, that are created on the stack or the heap.
Touretzky is clearly talking about these pointers, along with
the symbol's value cell, as separate entities.  He implies that
a variable is a particular pointer binding the name/symbol to a value.
It could be on the stack or the heap, or it could be the symbol's
value cell.

This seems to be reinforced by the hyperspec definition:
 > variable n. a binding in the ``variable'' namespace.


But, since people regularly talk about "special variables",
these statements seem to suggest otherwise:
 > Syntax: (special var*)
 > Arguments: var---a symbol.
and
 > > In this example, X is a global special variable, ...
 > To clarify, things defined by DEFVAR and DEFPARAMETER
 > are proclaimed SPECIAL.  binding a variable usually
 > shadows outer declarations about the variable.

They don't apply to individual pointers on the stack or heap or
value cell, they apply to the name/symbol itself.  You can't declare
an individual pointer/binding to be special, you have to apply that
property to the name/symbol.

So it seems like the word "variable" is being used to mean
two different things.  Sometimes it's an individual
binding/pointer, other times it's the name/symbol itself.
I'm probably being very pedantic, but I think it helps,
unless there's some other point that I still haven't grasped.

-- 
Dan
www.prairienet.org/~dsb/
From: Duane Rettig
Subject: Re: symbol-value returns lexical value?
Date: 
Message-ID: <o0d51svs96.fsf@gemini.franz.com>
Dan Bensen <··········@cyberspace.net> writes:

> What triggered my question in this thread is a section
> in David Touretzky's "Gentle Introduction"
> http://www.cs.cmu.edu/~dst/LispBook/index.html
> Page 168--70 in the pdf, 156--8 in the book:
>> (setf a 100)
>> (defun f (a) (list a (g (+ a 1))))
>> (defun g (b) (list a b))
>> In this example, we create a global variable named A with value 100.
>> When we call F, it creates a local variable named A, with value 3,
>> Symbols are never bound; only variables can be bound.
>> And there is no unique variable named A; there are two.
>> Even while F's local variable A is in existence,
>> the global A can be referenced by functions such as G
>
> When I made my list of data structures, I guess I left out pointers,
> i.e. lexical bindings, that are created on the stack or the heap.
> Touretzky is clearly talking about these pointers, along with
> the symbol's value cell, as separate entities.  He implies that
> a variable is a particular pointer binding the name/symbol to a value.
> It could be on the stack or the heap, or it could be the symbol's
> value cell.

Forget about "pointers".  They are seldom mentioned in Common Lisp,
and when they are they are usually not the kind of pointers you are
used to, but are indices instead (e.g. a fill-pointer for an array).
Look instead at the definition of "binding", which has no references
to "pointers", but instead speaks of "associations".  It is a subtle
difference, but once you remove your C-style of thinking about
pointers, you will be on your way to understanding this difference.
Unfortunately you have tuned in on a misguided attempt at teaching in
the book you are reading; first, if he talks about pointers, it is
only an attempt to relate to a non-lisp understanding of things,
mostly in implementational terms.  Also, one phrase you quote is
not strictly true: "Symbols are never bound; only variables can be
bound", for the very reason you stated earlier - it makes no sense to
bind a binding; a binding is an association between a name and a
value, and a variable _is_ that binding (one that happens to be in the
variable namespace).  Thus, a symbol, when it serves as a name in the
dynamic variable space (se the definition of defvar and defparameter,
for example) can certainly have a binding, and a variable is not
itself bound (note that the glossary definition of "unbound variable"
refers to a name that has no binding, not a variable that has no
binding).  Some of this is confusing because most Lispers mix these
terms freely without much confusion (unless they think about it).  As
an example of how we do the same thing in English, consider the
sentence "He went to the store with Joe and I".  Perhaps that rubs
non-English speakers the wrong way, but at least most Americans will
let it go (the correct sentence is "He went to the store with Joe and
me") and will in fact understand it perfectly.

> This seems to be reinforced by the hyperspec definition:
>> variable n. a binding in the ``variable'' namespace.

Yes, binding being an association between a name and a value (or,
literally, "that which the name denotes".  It happens to be in the
variable namespace, as opposed to e.g. the function namespace.  So a
name can be part of both a variable binding and a function binding.

> But, since people regularly talk about "special variables",

That's because special variables are ... well,  special.

> these statements seem to suggest otherwise:
>> Syntax: (special var*)
>> Arguments: var---a symbol.

Yes, that is what the argument must be in a conforming program - a
symbol.  Note that in the definition of DEFVAR and DEFPARAMETER
you also found below, the Arguments section includes an argument named
"name", which is also a symbol.  So a symbol can represent a name, or
it can represent itself, an actual symbol.  In this case, it is a
symbol which is intended to serve as a name for a binding.

> and
>> > In this example, X is a global special variable, ...
>> To clarify, things defined by DEFVAR and DEFPARAMETER
>> are proclaimed SPECIAL.  binding a variable usually
>> shadows outer declarations about the variable.

Note also that these definitions specifically call for the
implementation by mentioning the "value cell" (look that one up, also)
and also implying that these specials can be "bound" or "unbound".

> They don't apply to individual pointers on the stack or heap or
> value cell,

Pointers again; no, of course not.  But value cells?  For specials,
this is explicitly called for by defvar/defparameter.  For more help
on this, see the definition of "special variable" and follow it
through.

 they apply to the name/symbol itself.  You can't declare
> an individual pointer/binding to be special, you have to apply that
> property to the name/symbol.

> So it seems like the word "variable" is being used to mean
> two different things.  Sometimes it's an individual
> binding/pointer, other times it's the name/symbol itself.
> I'm probably being very pedantic, but I think it helps,
> unless there's some other point that I still haven't grasped.

I don't see such double meanings; I see variables always used to mean
bindings, whether lexical or dynamic.  Perhaps you take the mention of
"var--a symbol" to imply that the symbol is itself a variable, but
really this is a semantic nit; it is the case that definition for the
special declaration is talking about symbols that are _intended_ to be
names of variables (i.e. names with bindings to values, if you will).

-- 
Duane Rettig    ·····@franz.com    Franz Inc.  http://www.franz.com/
555 12th St., Suite 1450               http://www.555citycenter.com/
Oakland, Ca. 94607        Phone: (510) 452-2000; Fax: (510) 452-0182   
From: Dan Bensen
Subject: Re: symbol-value returns lexical value?
Date: 
Message-ID: <f0n4p1$5mk$1@wildfire.prairienet.org>
Duane Rettig wrote:
> Unfortunately you have tuned in on a misguided attempt at teaching in
> the book you are reading; first, if he talks about pointers, it is
> only an attempt to relate to a non-lisp understanding of things,

No, that's all me.  Seven years of C/C++ :)

> mostly in implementational terms.  Also, one phrase you quote is
> not strictly true: "Symbols are never bound; only variables can be
> bound", for the very reason you stated earlier - it makes no sense to
> bind a binding; a binding is an association between a name and a
> value, and a variable _is_ that binding (one that happens to be in the
> variable namespace). 

Thank you, that's what I was looking for.

> itself bound (note that the glossary definition of "unbound variable"
> refers to a name that has no binding, not a variable that has no
> binding).  Some of this is confusing because most Lispers mix these
> terms freely without much confusion (unless they think about it). 

Including the hyperspec:
 > defparameter and defvar establish name as a dynamic variable.

>> They don't apply to individual pointers on the stack or heap or
>> value cell,
> Pointers again; no, of course not.  But value cells?  For specials,
> this is explicitly called for by defvar/defparameter.

That's fine.  I was just trying to think of all the places that
could hold a binding.

-- 
Dan
www.prairienet.org/~dsb/
From: Ken Tilton
Subject: Re: symbol-value returns lexical value?
Date: 
Message-ID: <PiCXh.245$c%5.94@newsfe12.lga>
Dan Bensen wrote:
> What triggered my question in this thread is a section
> in David Touretzky's "Gentle Introduction"
> http://www.cs.cmu.edu/~dst/LispBook/index.html
> Page 168--70 in the pdf, 156--8 in the book:
>  > (setf a 100)
>  > (defun f (a) (list a (g (+ a 1))))
>  > (defun g (b) (list a b))
>  > In this example, we create a global variable named A with value 100.
>  > When we call F, it creates a local variable named A, with value 3,
>  > Symbols are never bound; only variables can be bound.
>  > And there is no unique variable named A; there are two.
>  > Even while F's local variable A is in existence,
>  > the global A can be referenced by functions such as G
> 
> When I made my list of data structures, I guess I left out pointers,
> i.e. lexical bindings, that are created on the stack or the heap.
> Touretzky is clearly talking about these pointers, along with
> the symbol's value cell, as separate entities.  He implies that
> a variable is a particular pointer binding the name/symbol to a value.
> It could be on the stack or the heap, or it could be the symbol's
> value cell.
> 
> This seems to be reinforced by the hyperspec definition:
>  > variable n. a binding in the ``variable'' namespace.
> 
> 
> But, since people regularly talk about "special variables",
> these statements seem to suggest otherwise:
>  > Syntax: (special var*)
>  > Arguments: var---a symbol.
> and
>  > > In this example, X is a global special variable, ...
>  > To clarify, things defined by DEFVAR and DEFPARAMETER
>  > are proclaimed SPECIAL.  binding a variable usually
>  > shadows outer declarations about the variable.
> 
> They don't apply to individual pointers on the stack or heap or
> value cell, they apply to the name/symbol itself.  You can't declare
> an individual pointer/binding to be special, you have to apply that
> property to the name/symbol.
> 
> So it seems like the word "variable" is being used to mean
> two different things.  Sometimes it's an individual
> binding/pointer, other times it's the name/symbol itself.
> I'm probably being very pedantic, but I think it helps,
> unless there's some other point that I still haven't grasped.
> 

I feel a naggum coming on. You are not being pedantic, you are bringing 
your C understanding to Lisp. Please stop. Jesus H., you are talking 
about stacks!!!? And you cannot even program in Lisp yet!??? God I love 
it when noobs try to blend implementation with syntax.

Try this:

(let ((gizmo 42)) (symbol-value 'gizmo))
-> Error: you are clueless

The language lawyers cannot save you. I am your only hope. I am a simple 
application programmer.

(1) Forget (declare (special your-mama))
(2) Use defvar/defparameter...
(3) ...on things called *thing*
(4) Never use *anything* as a local variable name
(5) STFU and get back to work. *things* will work as you expect, as will 
things.

Too easy?

hth,kxo


-- 
http://www.theoryyalgebra.com/

"Algebra is the metaphysics of arithmetic." - John Ray

"As long as algebra is taught in school,
there will be prayer in school." - Cokie Roberts

"Stand firm in your refusal to remain conscious during algebra."
    - Fran Lebowitz

"I'm an algebra liar. I figure two good lies make a positive."
    - Tim Allen
From: Rob Warnock
Subject: Re: symbol-value returns lexical value?
Date: 
Message-ID: <H8Odna8j0qXvt7LbnZ2dnUVZ_viunZ2d@speakeasy.net>
Kent M Pitman  <······@nhplace.com> wrote:
+---------------
| I tried to get global lexicals into the language, but the attempt failed.
| See info on failed X3J13 issue PROCLAIM-LEXICAL at 
| http://www.nhplace.com/kent/CL/Issues/proclaim-lexical.html
| There's no provision for it in the language, but it's an easy user
| program to write.  DEFINE-SYMBOL-MACRO is the operator you need,
| and you can google for prior discussion on how to set it up.
+---------------

Here's a version I posted just a few months ago:

    (defmacro deflex (var val &optional (doc nil docp))    
      (let ((backing-var (intern (concatenate 'string
					      (symbol-name '#:*deflex-var-)
					      (symbol-name var)
					      (symbol-name '#:*))
				 (symbol-package var))))
	`(progn
	   (defparameter ,backing-var ,val ,doc)
	   ,@(when docp `((setf (documentation ',var 'variable) ,doc)))
	   (define-symbol-macro ,var ,backing-var))))


-Rob

p.s. Reminder: If you're running CMUCL-19c or earlier, you will
need the path to MACROEXPAND-1 that I posted on 2006-12-18
[Message-ID: <································@speakeasy.net>]
or you will have problems with SETF expanders which reference
DEFLEX'd variable names.

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Pascal Costanza
Subject: Re: symbol-value returns lexical value?
Date: 
Message-ID: <598d34F2jt3hfU1@mid.individual.net>
Dan Bensen wrote:
>  From the hyperspec:
> 
> http://www.lisp.org/HyperSpec/Body/mac_defparametercm_defvar.html#defvar
>  > defparameter and defvar establish name as a dynamic variable.
> 
> http://www.lisp.org/HyperSpec/Body/acc_symbol-value.html#symbol-value
>  > symbol-value cannot access the value of a lexical variable.
> 
> What's going on here?  I thought this wasn't supposed to happen:
> 
> sbcl 1.0.3:
> 
> * (defvar x 1)
> X
> * x
> 1
> * (let ((x 2)) (symbol-value 'x))
> 2

Special (dynamic) variables and lexical variables are two different 
kinds of variables. As soon as you define a special variable with defvar 
or defparameter, you implicitly proclaim that _each and every 
occurrence_ of the respective variable is special. That's why it's 
strongly advisable to follow the naming convention for special variables 
to use asterisks before and after the name of a special variable - this 
effectively creates a new namespace for special variables (only by 
convention, though).

You can get the same effect as in your example above as follows:

(let ((x 2))
   (declare (special x))
   (symbol-value 'x))

Here is even another way to get the same effect:

(progv (list 'x) (list 2)
   (symbol-value 'x))

As soon as you say (defvar x 1), (defparameter x 1), or (declaim 
(special x)) for that matter, the following two pieces of code are 
equivalent:

(let ((x 2))
   (symbol-value 'x))

(let ((x 2))
   (declare (special x))
   (symbol-value 'x))


On a related note, ISLISP has a slightly better design for the 
separation of dynamic and lexical variables. In ISLISP, these two kinds 
of variables have their own namespaces whose separation is enforced by 
the language. In ISLISP, you introduce dynamic variables with defdynamic 
(similar to defvar and defparameter), read them with dynamic and bind 
them with dynamic-let. Lexical variables can be introduced by defglobal 
and accessed via their names and bound via let. Your code above in 
Common Lisp is equivalent to the following code in ISLISP:

(defdynamic x 1)

(dynamic-let ((x 2)) (dynamic x)) => 2

What you apparently expected to happen is this:

(defdynamic x 1)

(let ((x 2)) (dynamic x)) => 1

There is no (straightforward) way in Common Lisp to say the latter.

See http://islisp.info/ for more information about ISLISP.


Pascal

-- 
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: Dan Bensen
Subject: Re: symbol-value returns lexical value?
Date: 
Message-ID: <f0n2vd$54g$1@wildfire.prairienet.org>
Pascal Costanza wrote:
> As soon as you define a special variable with defvar or
> defparameter, you implicitly proclaim that _each and every 
> occurrence_ of the respective variable is special.

That's probably what I meant when I said def{var|parameter} sets
a property of the identifier rather than one particular binding:
 > You can't declare an individual pointer/binding to be special,
 > you have to apply that property to the name/symbol.

And, if I understand you correctly, I don't think you really mean
"occurances of the [same] variable".  According to everything except
defvar and defparameter, each binding is a separate variable with
the same name.

I guess I was wrong when I said you can't make a single binding
special.  It's just that defvar operates on _all_ bindings of
an identifier, so saying it defines a single "special variable"
confuses the one identifier with all of its bindings.

> What you apparently expected to happen is this:
> (defdynamic x 1)
> (let ((x 2)) (dynamic x)) => 1

Yes, exactly.  That's what I thought this meant:
http://www.lisp.org/HyperSpec/Body/acc_symbol-value.html#symbol-value
 > symbol-value cannot access the value of a lexical variable.

It looks like it accesses a lexical binding, I guess because
x and (symbol-value 'x) have the same value inside the LET form:

* (let ((x 2)) (symbol-value 'x))
2
* x
1

So the term "variable binding" is somewhat confusing, because
it's partially redundant.  To me, it originally sounded like
it meant a binding between an identifier, which I thought was
the variable, and a value.  But the most common usage seems
to be that the binding IS the variable.

-- 
Dan
www.prairienet.org/~dsb/
From: Pascal Costanza
Subject: Re: symbol-value returns lexical value?
Date: 
Message-ID: <598iciF2hp91sU1@mid.individual.net>
Dan Bensen wrote:

> So the term "variable binding" is somewhat confusing, because
> it's partially redundant.  To me, it originally sounded like
> it meant a binding between an identifier, which I thought was
> the variable, and a value.  But the most common usage seems
> to be that the binding IS the variable.

Yes, because most of the time, it's clear what is meant. There are 
situations where it's good to be more precise, but they are rare.


Pascal

-- 
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: Dan Bensen
Subject: Re: Thanks for the help, everybody.
Date: 
Message-ID: <f0o1e8$f15$1@wildfire.prairienet.org>
Thanks to everyone who responded to this thread.
It's all appreciated.

-- 
Dan
www.prairienet.org/~dsb/