emacs-devel
[Top][All Lists]
Advanced

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

Re: Why is Elisp's defvar weird? And is eval_sub broken?


From: Stefan Monnier
Subject: Re: Why is Elisp's defvar weird? And is eval_sub broken?
Date: Sat, 14 Feb 2015 09:36:16 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

> A declaration of free dynamic variables for a function could tell the
> byte compiler that those free variables aren't typos, since
> otherwise the byte compiler would expect either the symbol to be
> declared special or a lexical variable by that name to be in scope.

There is such a declaration already.  It's called (defvar <foo>).  Tada!

>> Normally, such conflicts should never happen
>> because all special vars should be named with a "package prefix", but
>> sadly, reality is different, so it was indispensable to make this
>> effect local, to allow lexical-binding code to work reliably.
> By using llet, the byte compiler will catch such conflicts, and your code
> (interpreted or compiled) that uses it will work reliably despite the
> conflicts. This means defvar's weird behavior is no longer needed.

It's not weird once you understand that it's a compiler directive which
is absent from the .elc file.


        Stefan



reply via email to

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