guile-devel
[Top][All Lists]
Advanced

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

Elisp lexical-let


From: Daniel Kraft
Subject: Elisp lexical-let
Date: Tue, 21 Jul 2009 21:48:03 +0200
User-agent: Thunderbird 2.0.0.0 (X11/20070425)

Hi again,

I just had some doubts about the details of lexical-let for elisp, which seem to be not answered by the document I linked to... Maybe you can clarify these to me.

Especially, the question is about "what happens" when a lexical variable is inside its scope again bound dynamically (say via let or a lambda expression). Like in this example (I'm not sure if all my expected outputs are right, please correct me as needed):

(defvar x 1)
(defun foo () x)
(lexical-let ((x 2))
  x ; -> 2
  (foo) ; -> 1
  (setq x 3)
  x ; -> 3
  (foo) ; -> 1
  (let ((x 4))
    x ; -> 4?
    (foo) ; -> 4
    (setq x 5)
    x ; -> 5
    (foo) ; -> 5
    ) ; end the let
  x ; -> 3?
  (foo) ; -> 4
  )
x ; -> 4
(foo) ; -> 4

So in this case all references to x in the lexical scope of the let are to the dynamic value again, while the lexical is untouched and restored after leaving the let?

Have a nice evening!

Daniel

--
Done:  Arc-Bar-Cav-Ran-Rog-Sam-Tou-Val-Wiz
To go: Hea-Kni-Mon-Pri




reply via email to

[Prev in Thread] Current Thread [Next in Thread]