guile-devel
[Top][All Lists]
Advanced

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

Re: Elisp lexical-let


From: Daniel Kraft
Subject: Re: Elisp lexical-let
Date: Wed, 22 Jul 2009 11:11:27 +0200
User-agent: Thunderbird 2.0.0.0 (X11/20070425)

Ken Raeburn wrote:
On Jul 21, 2009, at 15:48, Daniel Kraft wrote:
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).

Oh, don't stop there... let's get some buffer-local or frame-local bindings into the mix too! :-) There are probably corner cases where the only "specification" you're likely to find is "what Emacs does when you try it". And, if the goal is to support the existing body of Lisp code (e.g., if Emacs 24 goes out with lexical binding support, and people start using it), there's a tradeoff between what seems logical or convenient to you, and what behavior of Emacs the existing code is going to expect. Maybe not in weird corner cases, but cases like you describe above seem likely, and I think you'd want to mimic whatever behavior Emacs is going to do.

It seemed really hard to me to find at least *basic* information about how the lexbind things works; I did build now an emacs with lexbind from trunk, but so far as I see this is not meant to implement "lexical-let" as the cl package does, but rather allows switching all bindings from dynamic to lexical within one source file.

While this is certainly something we could do, too (best via compiler options, I guess?), it is not what I had in mind as the "extension" -- this being implementing the lexical-let as additional construct that establishes lexical binding for certain variables just temporarily.

And checks with the cl package's implementation of lexical-let give the result, that an inner let does the same as if it was another lexical-let; that is, does not revert to dynamic binding but rather sets only the lexical value.

So, what are the opinions regarding lexical-let as an extension construct? Regarding the behaviour, to me the one described above seems to be a consequence of the implementing with unwind-protect and not necessarily expected -- thus I suggest to implement the version I had in mind, namely that an inner let or argument binding inside a lambda reverts to dynamic binding for that inner scope. This seems more consistent and reasonable to me.

Yours,
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]