Hi,
thanks for your comments; I'm still a bit confused, though :$
Marijn Schouten (hkBst) wrote:
What's about this:
(defun test () a)
(let ((a 1))
(print a) ; 1
(print (test)) ; 1
(lexical-set! a 2)
there is only one variable `a' in my mental model,
so this changes the value of the only `a' and all
subsequent expressions accessing `a' are thus affected.
The same as if you had written `(set! a 2)'. Dynamic
and lexical only differ in how free variables in
procedures are bound.
(print a) ; 1?
no, (print a) => 2
(print (test)) ; 1
no, there is only one `a' and its value is 2 here
(print (lexical a)) ; 2
)
Hm... my problem is trying to understand how you want this implemented;
my main point about lexical scoping is that it enables us to use Guile's
built-in lexical mechanisms and we don't have to save the value
explicitly into some fluids.
But if you require that the second (print (test)) above prints 1 even
though we have done (lexical-set! a) this means that lexical-set! must
update the place somehow where a is accessed dynamically (as is done in
test). And that seems to imply that this lexical-set! updates the
fluids, even though it is meant to perform on a lexically bound variable
a; just in case that "the one" a is at some place referred to dynamically.
I don't think it's good to have to "completely seperate" variables a and
(lexical a).
I don't understand what you mean. My proposal is to have one kind of variable
and two kinds of access.
Can you please elaborate on this? If there's only one variable and only
the value 2 after the lexical-set! above (both for (print a) in the
lexical scope and (print (test)) which accesses a dynamically), what
would then be the point of writing 'a' or '(lexical a)' and what would
be the difference between those two?
Yours,
Daniel
--
Done: Arc-Bar-Cav-Ran-Rog-Sam-Tou-Val-Wiz
To go: Hea-Kni-Mon-Pri