emacs-devel
[Top][All Lists]
Advanced

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

Re: lexical-binding defined by the caller not the called?


From: Stefan Monnier
Subject: Re: lexical-binding defined by the caller not the called?
Date: Sat, 04 May 2013 16:01:27 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

>>> How do I check for lexical-binding then?
>> Read again the code I posted along.
> I did.  I can't see how that shows me how to test lexical-binding though.
> It seems like I can't tell if I'm executing in a lexical-binding
> environment or not.

> I want to be able to write a macro that understands when it is, or is
> not, executing code inside a lexical-binding environment.

It's a good question.  But you need to be careful about what you mean
because the code you showed does not do what you describe (e.g. it
doesn't do any macro expansion).

Testing the value of `lexical-binding' from within a function won't
tell you if that function is itself using lexical binding or not.

But testing `lexical-binding' during macro expansion should tell you
whether the expanded code will be interpreted as lexically scoped
or not.  It's actually not 100% reliable (e.g. lexical-binding is
a buffer-local variable, so if you switch buffer during your macro
expansion, you might bump into some corner cases), but it should work
well in practice (tho less so in 24.1 where there were a few more
problematic cases that I had forgotten).


        Stefan



reply via email to

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