help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Real-life examples of lexical binding in Emacs Lisp


From: Stefan Monnier
Subject: Re: Real-life examples of lexical binding in Emacs Lisp
Date: Sun, 14 Jun 2015 16:04:31 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

>> However, I would argue that for global variables, lexical binding would
>> be useful too, even by default.

I'm not sure what that means.  But you can set a global value to
a variable without declaring it as dynamically scoped:

    (setq my-lex-var 3)

Inside Emacs we also have a few global vars (e.g. `pi' and `argv') which
we would want to declare with something like defvar for various reasons
(providing a docstring, recording where is the declaration, etc...) yet
we don't want them to be dynamically scoped.

For `pi' we just used `setq', and for `argv' we used defvar followed by
an ugly hack called internal-make-var-non-special.


        Stefan


reply via email to

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