thelif...@gmx.net (thelifter) writes: > Alain Picard <apicard+die-spammer-...@optushome.com.au> wrote in message <news:87r8dnoxy2.fsf@optushome.com.au>... > > Ok, try this. Forget the word "variable" for a moment. There ARE no > > "variables". There are only symbols and values. When you evaluate an
> I just took a look at the language specification. It seems that the > main problem is, that there is no definition for variable:
Please understand that I offered this explanation in the context of a guide "for idiots" (God I hate that term). Of course there _are_ variables, both in execution and in the spec---refer to Kent's reply to my previous post to see what that's all about.
But if you want to get a temporary mental model for how things work, I offered you one. It's, by design, incomplete and inaccurate.
Erik Naggum <e...@naggum.no> writes: > * Nils Goesche > | And here is where I erred: There /is/ a global lexical > | environment; it is called the null lexical environment, and > | it is here where the binding is established.
> This is very confused. The "null lexical environment" > communicates to the alert reader that there are no lexically > apparent bindings, not that any new bindings are established > in it.
Well, yes. Maybe I shouldn't use the term ``null lexical environment´´ when talking about it.
> That `eval´ is evaluated in the null lexical environment > means that it cannot access lexically apparent bindings, > which `eval´ does not attempt to capture bindings when it > receives a form.
Sure. What I am trying to understand is the following:
There is indeed no lexically apparent binding for those two symbols. But their values are looked up somewhere, in an environment. Which is it?
The global environment, obviously, which is also called ``null lexical environment´´ to emphasize that it contains no lexically apparent bindings (see 3.1.1.3.1 The Null Lexical Environment). Neither MOST-POSITIVE-DOUBLE-FLOAT nor X have been declaimed special, however.
Now, MOST-POSITIVE-DOUBLE-FLOAT is a constant, which is not so interesting, but X is not. I can do
CL-USER 33 > (setf (symbol-value 'x) 17) 17
CL-USER 34 > (eval 'x) 17
anytime I want. I can also do
CL-USER 35 > (let ((x 13)) (+ x 5)) 18
I would also like to try the following:
(defun test (y) (+ x y))
(let ((x 20)) (test 7))
Now, 3.2.2.3 Semantic Constraints says:
# Special proclamations for dynamic variables must be made in the # compilation environment. Any binding for which there is no # special declaration or proclamation in the compilation # environment is treated by the compiler as a lexical binding.
But I might snottily claim that I don't want X to be special, anyway :-)
But what the heck, let's do it anyway:
CL-USER 36 > (defun test (y) (+ x y)) Warning: Syntactic warning for form X: X assumed special. TEST
CL-USER 37 > (let ((x 20)) (test 7)) 24
as expected.
Whether this is legal code or not is not so interesting at the moment; what I like is that we can explain everything that happened in the above experiments without resorting to implementation issues if we simply say that X is part of such a thing as a ``global lexical environment´´. While this sounds a bit like an oxymoron because lexical bindings are usually lexically restricted to establishing forms and have dynamic extent, it is well possible to give the term a reasonable meaning.
Now, what happens if we do
CL-USER 38 > (declaim (special x)) NIL
CL-USER 39 > (let ((x 20)) (test 7)) 27
By globally declaring X special, we instruct the system to perform the last binding in the dynamic environment, instead. It is rather puzzling that TEST already behaves accordingly, too! So, now X is also part of the (global) dynamic environment, obviously. And it has kept its value :-)
Christian Queinnec writes in ``Lisp in Small Pieces´´ (p. 50):
# In addition, if we do not find the dynamic value, then we go # back to the global lexical environment, since it also serves as # the global dynamic environment in Common Lisp.
> [split explanations]
Thank you for those, but I think I already understood this. The above is the point I am a bit confused about :-)
Note that my problem does not stem from confusing symbols with variables. My (SETF SYMBOL-VALUE) actions are one thing, not very interesting; the interesting part is explaining the evaluations, semantically.
All these considerations are certainly rather esoteric, idle speculation. What /really/ goes on under the hood in the implementation is perfectly clear, anyway; but I find it interesting, anyway.
Regards, -- Nils Gösche Ask not for whom the <CONTROL-G> tolls.
Ok, and the interesting part is that your code does not look like it manipulates a data structure, anymore. You are using only abstract operators for setting variables. I can achieve the same thing in bash:
#!/bin/bash
set_symbol_value () { eval "$1=$2"
}
x=2
set_symbol_value x 4
echo $x
will output 4. The values don't come from a symbol data structure anymore but have to be explained purely semantically.
> > It is interesting insofar as it emphasizes that you don't > > need SYMBOL-VALUE to understand variables in Common Lisp, I > > think.
> You don't need the symbol-value function, but I don't see how > you can understand variables in CL without the *concept* of a > symbol's value (or its dynamic binding or whatever you want to > call it).
By not calling it the ``symbol's´´ value. Variables have values; a symbol is just some arbitrary data structure. Sure, Lisp code is made up of conses and symbols, but as soon as it is /evaluated/, it doesn't matter anymore what kind of thing a symbol actually is and if it has something like a value slot or not. That's an implementation issue. As soon as a symbol is evaluated (and it is not a symbol macro ;-), it is used to denote the /name/ of a /variable/. The level of abstraction is higher.
> BTW, a number of people have written to me to say that symbols > have nothing to do with lexical bindings. This is false. The > semantics of lexical bindings in Common Lisp are defined in > such a way that a compiler *may* optimize away the symbols, but > the semantics of lexical variables are defined in the standard > in terms of symbols. (Also, most implementations keep the > symbols around for debugging.)
This is just a variation of the above.
Regards, -- Nils Gösche Ask not for whom the <CONTROL-G> tolls.
| My God, how annoying it is to try to explain something to people who | are unwilling to listen because they believe they already understand | things better than their teachers.
Yeah, but I still prefer the student who tells me I am wrong, as long as he gives a reason for thinking so. It is only if he persists after his mistake has been pointed out to him that he becomes annoying.
I am not denying that this often happens on Usenet, of course.
| Harald Hanche-Olsen <han...@math.ntnu.no> writes: | | > Only if you worry about such esoterica as how to construct the | > natural numbers given nothing more than set theory do you dream | > up seemingly crazy schemes such as 0={} (the empty set), 1={0}, | > 2={0,1}, etc. | | I don't see what's crazy about that.
Neither do I, which is why I wrote "seemingly". But when I was first exposed to the idea, way back in the mists of time, I did think it was crazy, at least until the idea began to sink in and I realized the elegance of it all (as you describe so eloquently).
| The question ``What /is/ a variable, after all?´´ is likewise | interesting.
Even more so in mathematics than in computing, methinks. I have never understood why the induction principle seems to be so difficult to grasp, but it is an observable fact that many students fail to get it. Actually, I think it is not the induction principle /per se/ that confuses people, but that they have a more fundamental problem in understanding what mathematics is all about, and in particular in grasping the notion of a variable. If you haven't got a firm grip on that, a proof by induction really seems circular, and so the students are left wondering why they are told not to employ circular reasoning, and yet, within the framework of induction, it is OK to do so?
I think the situation is very similar with respect to the notion of variables in Lisp. Once you get it, it is blindingly obvious, but when you try to explain this insight, you're still groping for words. (And personally, I find I still struggle with the terminology, as evidenced by an earlier posting of mine in this thread.)
> Using this implementation you can set the symbol-value of any > Lisp object, not just symbols.
Sure. But the very notations (symbol-value 'x) or (setf (symbol-value 'x) 42) look exactly as if somebody did a (defstruct symbol ((value ...) ...) before. We are talking about conceptual models for describing the semantics of Lisp variables. If you avoid, for the moment, the SYMBOL-VALUE way of accessing a (dynamic) variable's value it becomes clearer, for beginners, that this is about evaluation, scope and environments of variables and that you can perfectly understand their behavior without thinking of a symbol as a data structure with a slot that contains the value of the variable it denotes (which would give you the wrong idea for lexical variables, anyway). As I said, Lisp code is made up of symbols and conses (and other atoms!), but as soon as we are trying to describe the semantics of the /code/ this tree structure of objects /represents/, it is better to get away as far as possible from the physical representation of our code when we describe its /meaning/. Once this has been understood, and only then, we can get to the additional cutie that we can /also/ access the /semantic/ value of a dynamic variable by accessing a physical ``value´´ slot of the symbol, the data structure, that is used to represent it.
Regards, -- Nils Gösche Ask not for whom the <CONTROL-G> tolls.
In article <87ptt6cr3a....@darkstar.cartan>, Nils Goesche <n...@cartan.de> wrote: > The question ``What /is/ a variable, after all?´´ is likewise > interesting.
Indeed.
The standard says:
A variable is a binding in the variable namespace. A binding is an association between a name and that which the name denotes. A namespace is [a set of] bindings whose denotations are restricted to a particular kind.
My latest attempt to distill this for a revised version of TIG2SV:
A variable is a storage location that has a name. (Or a variant suggested by Len Charest: a variable is a storage location that is identified by an identifier.)
E.
---
<tangent>
On a challenge from Crispin Sartwell's website I once took a stab at trying to define the word "seven". Here's what I came up with FWIW:
ZERO is a description of the non-existence of things. It is usually applied to a particular kind of thing defined by a particular set of properties within a particular context. "There are zero cows in my office" means that within the context of my office there does not exist a thing with the set of properties for which we use the shorthand notation "cow".
ONE is a description of a particular kind of existence characterized by the following property: there exists ONE (thing) if and only if it is not possible to partition it into a subset and its complement such that both the subset and its complement have the properties that define it. If you have ONE cow then it is not possible to partition that cow into a subset and its complement such that both the subset and its complement are cows.
Note that this partitioning is a *mental* partitioning, not a physical one. This allows us to, for example, take a collection of cows and call it ONE herd of cows by stipulating that one of the essential properties that defines a herd is that it have a boundary beyond which there are no cows.
TWO is a description of a particular kind of existence characterized by the following property: there exist TWO (things) if and only if it is possible to partition the context within which they exist into a subset and its complement such that there is ONE in the subset and ONE in the complement.
Note that there is an asymmetry here. To decide whether there is ONE of something you have to partition the THING, but to decide whether there is TWO of something you have to partition the CONTEXT. Thus, for some collections of cows, it can be correct to say that there is both ONE and TWO herds of cows depending on exactly how you choose to define a herd.
In general, if it is possible to partition a context such that there are X in the subset and Y in the complement then we say that there exist X PLUS Y. Thus, TWO is ONE PLUS ONE. THREE is TWO PLUS ONE (which is the same as ONE PLUS ONE PLUS ONE) etc. Seven is three plus two plus two.
g...@jpl.nasa.gov (Erann Gat) writes: > In article <87ptt6cr3a....@darkstar.cartan>, Nils Goesche <n...@cartan.de> wrote:
> > The question ``What /is/ a variable, after all?´´ is likewise > > interesting.
> Indeed.
> The standard says:
> A variable is a binding in the variable namespace. > A binding is an association between a name and that which the name denotes. > A namespace is [a set of] bindings whose denotations are restricted to a > particular kind.
> My latest attempt to distill this for a revised version of TIG2SV:
> A variable is a storage location that has a name. (Or a > variant suggested by Len Charest: a variable is a storage > location that is identified by an identifier.)
Quite good. I would like to be able to say ``A binding is an association between a name and a storage location.´´ This takes into account that the same name can denote different locations in different contexts. A variable would simply be a name, then, I guess.
> <tangent>
> On a challenge from Crispin Sartwell's website I once took a > stab at trying to define the word "seven". Here's what I came > up with FWIW:
Heh, nice. Call me weird, but I think that nothing can beat the poetic beauty of the correct answer, though:
I <n...@cartan.de> wrote: > While this sounds a bit like an oxymoron because lexical > bindings are usually lexically restricted to establishing forms > and have dynamic extent, [...]
Oops, scratch that dynamic extent thing.
Sorry, -- Nils Gösche Ask not for whom the <CONTROL-G> tolls.
* Nils Goesche | The global environment, obviously, which is also called ``null | lexical environment´´ to emphasize that it contains no lexically | apparent bindings (see 3.1.1.3.1 The Null Lexical Environment).
No, this is not right. That two things are the same in one respect does not make them the same in all respects, which they would have to be to be interchangeable. It is like `not´ and `null´.
| Whether this is legal code or not is not so interesting at the moment; | what I like is that we can explain everything that happened in the above | experiments without resorting to implementation issues if we simply say | that X is part of such a thing as a ``global lexical environment´´.
But there is no such thing. The whole point is that it is /not/ lexical.
| Christian Queinnec writes in ``Lisp in Small Pieces´´ (p. 50): | | # In addition, if we do not find the dynamic value, then we go | # back to the global lexical environment, since it also serves as | # the global dynamic environment in Common Lisp.
I believe this is more accurate for Scheme.
| What /really/ goes on under the hood in the implementation is perfectly | clear, anyway; but I find it interesting, anyway.
When the implementation is clear and the concepts are not, the conceptual model is wrong.
-- Erik Naggum, Oslo, Norway
Act from reason, and failure makes you rethink and study harder. Act from faith, and failure makes you blame someone and push harder.
Erik Naggum <e...@naggum.no> writes: > * Nils Goesche > | Christian Queinnec writes in ``Lisp in Small Pieces´´ (p. 50): > | > | # In addition, if we do not find the dynamic value, then we go > | # back to the global lexical environment, since it also serves as > | # the global dynamic environment in Common Lisp.
> I believe this is more accurate for Scheme.
Yes, probably.
> | What /really/ goes on under the hood in the implementation is > | perfectly clear, anyway; but I find it interesting, anyway.
> When the implementation is clear and the concepts are not, > the conceptual model is wrong.
Heh, quite right. I'll go think about it some more.
Regards, -- Nils Gösche Ask not for whom the <CONTROL-G> tolls.
In other words, it's one implementation of the number 7 (better: it's the number 7 in one implementation of the natural numbers). There are others, such as {{{{{{{{}}}}}}}} and { x : |x| = 7 } (er, obviously the latter won't do as it stands; it also won't work in ZF set theory, but it's fine in something like NF).
ObLisp:
(defstruct box x0 y0 x1 y1 children bordered)
(defun box-size (b) (values (- (box-x1 b) (box-x0 b)) (- (box-y1 b) (box-y0 b))))
(defun box-translate (b dx dy) (make-box :x0 (+ (box-x0 b) dx) :y0 (+ (box-y0 b) dy) :x1 (+ (box-x1 b) dx) :y1 (+ (box-y1 b) dy) :children (loop for child in (box-children b) collect (box-translate child dx dy)) :bordered (box-bordered b)))
(defun box-translate-to (b x y) (box-translate b (- x (box-x0 b)) (- y (box-y0 b))))
(defun box-surround (b delta) (make-box :x0 (- (box-x0 b) delta) :y0 (- (box-y0 b) delta) :x1 (+ (box-x1 b) delta) :y1 (+ (box-y1 b) delta) :children (list b) :bordered nil))
(defun flatten (b) (let ((rest (loop for child in (box-children b) nconc (flatten child)))) (if (box-bordered b) (cons (list (box-x0 b) (box-y0 b) (box-x1 b) (box-y1 b)) rest) rest)))
> In other words, it's one implementation of the number 7 > (better: it's the number 7 in one implementation of the > natural numbers). There are others, such as {{{{{{{{}}}}}}}} > and { x : |x| = 7 } (er, obviously the latter won't do as it > stands; it also won't work in ZF set theory, but it's fine > in something like NF).
I know. I meant it is my favorite among the correct answers. And it is certainly the most poetic ;-)
Erik Naggum <e...@naggum.no> writes: > * Nils Goesche > | The global environment, obviously, which is also called ``null > | lexical environment´´ to emphasize that it contains no lexically > | apparent bindings (see 3.1.1.3.1 The Null Lexical Environment).
> No, this is not right. That two things are the same in one respect does > not make them the same in all respects, which they would have to be to be > interchangeable. It is like `not´ and `null´.
Speaking frankly, I don't understand clearly what this phrase in `3.1.1.3.1 The Null Lexical Environment' means:
"The null lexical environment is equivalent to the global environment."
What the equivalence do they speak about? Do they mean that, like the global environment, the null lexical environment contains no lexical bindings? Or it might be that they speak about an equivalency in a sense of bindings for functions and macros and proclamations/declarations? I'm confused. :(
g...@jpl.nasa.gov (Erann Gat) writes: > I assumed he meant something deeper: no great harm would come if we > eliminated the functionality that symbol-value provides, under whatever > guises that functionality exists in the language (including the ability to > evaluate symbols at run time).
Aleksandr Skobelev <public-m...@list.ru> writes: > Erik Naggum <e...@naggum.no> writes:
> > * Nils Goesche > > | The global environment, obviously, which is also called ``null > > | lexical environment´´ to emphasize that it contains no lexically > > | apparent bindings (see 3.1.1.3.1 The Null Lexical Environment).
> > No, this is not right. That two things are the same in one > > respect does not make them the same in all respects, which > > they would have to be to be interchangeable. It is like > > `not´ and `null´.
> Speaking frankly, I don't understand clearly what this phrase in > `3.1.1.3.1 The Null Lexical Environment' means:
> "The null lexical environment is equivalent to the global > environment."
> What the equivalence do they speak about?
As I understand it, it means that whenever it says that a form is evaluated in the null lexical environment, like the argument to EVAL, for instance, it cannot access any lexically apparent bindings. The only bindings it /can/ access are those in the global environment and the current dynamic environment, but /no/ lexical ones.
> Do they mean that, like the global environment, the null > lexical environment contains no lexical bindings?
Yes. I was only wondering about if it would make sense to /introduce/ a notion of a global lexical binding when speaking about Common Lisp to make it easier to explain some freaky code snippets of questionable legal status. But whatever it was I was talking about it wasn't Common Lisp as defined by the HyperSpec.
> I'm confused. :(
I hope it wasn't me who caused that :-)
Regards, -- Nils Gösche Ask not for whom the <CONTROL-G> tolls.
* Aleksandr Skobelev | What the equivalence do they speak about?
Sigh. It means that when somebody says the "null lexical environment", the expressin contains relevant information about (at least) two things: (1) the perspective and (2) the object. The same holds for "the global environment", of course, in which case the object is the same as for the previous expression, but the /perspective/ is not.
| Do they mean that, like the global environment, the null lexical | environment contains no lexical bindings?
The global environment is what you get when you have no lexical bindings.
The point here is that the lexical environment shadows the global. When you have an empty/null lexical environment, you have nothing that could shadow the global environment, therefore the consequence of viewing your environment through the now empty/transparent lexical environment is that you see only the background global environment. But it is possible to look at the global environment /without/ looking through a transparent lexical environment that shadows nothing, hence the two perspectives have different names.
Think of bindings as squares on a blackboard. You can flip overlays over the blackboard from both sides, and the overlays can have opaque squares that shadow any other bindings but otherwise be transparent. Now, the overlays attached to one side holds overlays for special bindings while the other side holds lexical overlays, so you can flip them in from both sides. A `special´ proclamation means that you cut a whole in all the lexical overlays so that you will always see the dynamic bindings. When you make a special binding, you make an opaque square on an overlay you have flipped in from the special side and scribble on it. When you make a lexical binding, you make an opaque square on an overlay you have flipped in from the lexical side and scribble on it. When you call a function, you temporarily remove all your lexical overlays, but the special overlays remain, and you use a fresh set of lexical overlays. Now, if you make no lexical bindings on this fresh set of overlays, you have the null lexical environment. This is what `eval´ starts out with, just like any other function before it makes its own lexical bindings, such as for incoming arguments (which may also cause special bindings, btw).
Did that make the issue opaque or transparent?
And, please, there is no global lexical environment. While some evidently think it is descriptive of something, it is an oxymoron that only confuses people who do not understand what is going on.
-- Erik Naggum, Oslo, Norway
Act from reason, and failure makes you rethink and study harder. Act from faith, and failure makes you blame someone and push harder.
Nils Goesche <n...@cartan.de> wrote: +--------------- | As I understand it, it means that whenever it says that a form is | evaluated in the null lexical environment, like the argument to | EVAL, for instance, it cannot access any lexically apparent | bindings. The only bindings it /can/ access are those in the | global environment and the current dynamic environment, but /no/ | lexical ones. +---------------
Well, it *can*, of course, access any new lexical bindings introduced in the expression being EVAL'd, as well as any lexical bindings previously closed over by functions called by the EVAL'd code. You didn't really mean to exclude those when you said "/no/ lexical ones", did you?
To me, to say that "a form is evaluated in the null lexical environment" means that the *current* lexical environment is not accessible.
-Rob
----- Rob Warnock, PP-ASEL-IA <r...@rpw3.org> 627 26th Avenue <URL:http://www.rpw3.org/> San Mateo, CA 94403 (650)572-2607
Nils Goesche <n...@cartan.de> writes: > Aleksandr Skobelev <public-m...@list.ru> writes: > > "The null lexical environment is equivalent to the global > > environment."
> > What the equivalence do they speak about?
> As I understand it, it means that whenever it says that a form is > evaluated in the null lexical environment, like the argument to > EVAL, for instance, it cannot access any lexically apparent > bindings. The only bindings it /can/ access are those in the > global environment and the current dynamic environment, but /no/ > lexical ones.
Yes, but there is nothing about the current dynamic environment in that statement. So, it looks like we give some free interpretation for it.
> > Do they mean that, like the global environment, the null > > lexical environment contains no lexical bindings?
> Yes. I was only wondering about if it would make sense to > /introduce/ a notion of a global lexical binding when speaking > about Common Lisp to make it easier to explain some freaky code > snippets of questionable legal status.
Hmm, I'm not sure about how such a notion could be useful. It might be that some examples of such freaky code (if you can find some easily) could clear it.
Erik Naggum <e...@naggum.no> writes: > * Aleksandr Skobelev > | What the equivalence do they speak about?
> Sigh. It means that when somebody says the "null lexical environment", > the expressin contains relevant information about (at least) two things: > (1) the perspective and (2) the object. The same holds for "the global > environment", of course, in which case the object is the same as for the > previous expression, but the /perspective/ is not.
> | Do they mean that, like the global environment, the null lexical > | environment contains no lexical bindings?
> The global environment is what you get when you have no lexical bindings.
> The point here is that the lexical environment shadows the global. When > you have an empty/null lexical environment, you have nothing that could > shadow the global environment, therefore the consequence of viewing your > environment through the now empty/transparent lexical environment is that > you see only the background global environment. But it is possible to > look at the global environment /without/ looking through a transparent > lexical environment that shadows nothing, hence the two perspectives have > different names.
Hmm. It might be there is a mess in my poor head, but how about dynamic environments?
---------- * (setf x 10) Warning: This variable is undefined: X
Here the lexical binding to 30 shadows the dynamic binding to 20, which is in dynamic, but not the global environment. But eval sees 20, not 10. So, isn't null lexical environment equivalent to a some dynamic + the global environment?
> Think of bindings as squares on a blackboard. You can flip overlays over > the blackboard from both sides, and the overlays can have opaque squares > that shadow any other bindings but otherwise be transparent. Now, the > overlays attached to one side holds overlays for special bindings while > the other side holds lexical overlays, so you can flip them in from both > sides. A `special´ proclamation means that you cut a whole in all the > lexical overlays so that you will always see the dynamic bindings. When > you make a special binding, you make an opaque square on an overlay you > have flipped in from the special side and scribble on it. When you make a > lexical binding, you make an opaque square on an overlay you have flipped > in from the lexical side and scribble on it. When you call a function, > you temporarily remove all your lexical overlays, but the special overlays > remain, and you use a fresh set of lexical overlays. Now, if you make no > lexical bindings on this fresh set of overlays, you have the null lexical > environment. This is what `eval´ starts out with, just like any other > function before it makes its own lexical bindings, such as for incoming > arguments (which may also cause special bindings, btw).
> Did that make the issue opaque or transparent?
Sorry, I'm afraid I became enmeshed who has been overlaid by whom here. :)
Thank you. I think (well, I hope) I understand how fresh lexical/dynamic bindings shadow each other and bindings in the global environment. What I don't understand clear (and what I wrote about in my previous message) is the usage of 'equivalent' word in the standard. Does it have the strict technical or just some free, descriptive meaning? Just now it looks for me like it is just descriptive and not absolutly full (if remember about bindings in dynamic environments). But I suspect, that it might be something wrong in my reasoning. :(
> And, please, there is no global lexical environment. While some evidently > think it is descriptive of something, it is an oxymoron that only confuses > people who do not understand what is going on.
r...@rpw3.org (Rob Warnock) writes: > Nils Goesche <n...@cartan.de> wrote: > +--------------- > | As I understand it, it means that whenever it says that a form is > | evaluated in the null lexical environment, like the argument to > | EVAL, for instance, it cannot access any lexically apparent > | bindings. The only bindings it /can/ access are those in the > | global environment and the current dynamic environment, but /no/ > | lexical ones. > +---------------
> Well, it *can*, of course, access any new lexical bindings > introduced in the expression being EVAL'd, as well as any lexical > bindings previously closed over by functions called by the EVAL'd > code. You didn't really mean to exclude those when you said "/no/ > lexical ones", did you?
Of course not. Maybe I should say ``any bindings lexically apparent to EVAL where it is called´´.
> To me, to say that "a form is evaluated in the null lexical > environment" means that the *current* lexical environment is not > accessible.
Of course.
Regards, -- Nils Gösche "Don't ask for whom the <CTRL-G> tolls."
Aleksandr Skobelev <public-m...@list.ru> writes: > Nils Goesche <n...@cartan.de> writes:
> > Aleksandr Skobelev <public-m...@list.ru> writes:
> > > "The null lexical environment is equivalent to the global > > > environment."
> > > What the equivalence do they speak about?
> > As I understand it, it means that whenever it says that a form is > > evaluated in the null lexical environment, like the argument to > > EVAL, for instance, it cannot access any lexically apparent > > bindings. The only bindings it /can/ access are those in the > > global environment and the current dynamic environment, but /no/ > > lexical ones.
> Yes, but there is nothing about the current dynamic environment in > that statement. So, it looks like we give some free interpretation > for it.
I added ``the current dynamic environment´´ because EVALed forms can access it (see dictionary entry for EVAL) /and/ the null lexical environment:
(MOST-POSITIVE-FIXNUM available in the null lexical environment, because it is part of the global environment).
> > > Do they mean that, like the global environment, the null > > > lexical environment contains no lexical bindings?
> > Yes. I was only wondering about if it would make sense to > > /introduce/ a notion of a global lexical binding when speaking > > about Common Lisp to make it easier to explain some freaky code > > snippets of questionable legal status.
> Hmm, I'm not sure about how such a notion could be useful. It might > be that some examples of such freaky code (if you can find some > easily) could clear it.
I doubt it, but I posted some earlier in this thread.
Regards, -- Nils Gösche "Don't ask for whom the <CTRL-G> tolls."
Nice example, actually. Although you should somehow globally declare X special, maybe by using DEFPARAMETER instead of just SETF, to clear all doubt.
> Here the lexical binding to 30 shadows the dynamic binding to 20, > which is in dynamic, but not the global environment. But eval sees > 20, not 10. So, isn't null lexical environment equivalent to a some > dynamic + the global environment?
No. EVAL can access /both/ a null lexical environment (meaning the lexically apparent binding of x to 30 isn't visible) /and/ the current dynamic environment. This is a specialty of EVAL (see its dictionary entry) but has nothing to do with the term ``null lexical environment´´ in itself.
Regards, -- Nils Gösche "Don't ask for whom the <CTRL-G> tolls."