[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Another question about lexical closures



There's a little ambiguity about when two bindings are "the same" and when
they are "different" bindings. If you bind exactly the same lexical variable
(in the same function or other executable form) to exactly the same value
(the values are EQ), at two different times, are the two bindings you get
considered to be the same or different? I.e. if you make a lexical closure
in function FOO with X bound to NIL and then make another lexical closure
in function FOO with X bound to NIL, will the X-variables in those two
closures be the same variable (sharing side-effects) or not? My guess
is they will be different, that is each time you go into a lambda-binding
you get a "different" binding even if the lexical variable and its value
are the same both times. Am I correct? (Note the example at the bottom of
page 87 doesn't answer this question since TWO-FUNS is called only once.
If it got called a second time, with exactly the same args, and the result
SETQ'd to global FUNS2, would (CAR FUNS) and (CAR FUNS2) share their
lexical-closure-variable, i.e. "the binding of the variable X created
on entry to the function TWO-FUNS when it was called with argument 6"
as described at the bottom of the page? That phrasing indicates there
WOULD be sharing, but due to what it says on page 37 top "it depends
on the invocaton during which the reference is made" I think it WOULD NOT
be sharing, i.e. wording on page 87 should really say "... on that particular
entry to the function TWO-FUNS ..." even though in that example it is moot
since TWO-FUNS was called only once in the example.)
-------