[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: table.el
From: |
Miles Bader |
Subject: |
Re: table.el |
Date: |
02 Dec 2001 23:35:57 +0900 |
address@hidden (Kai Großjohann) writes:
> (let ((x 1))
> (some-func))
>
> With the current `let', x would be bound to 1 while some-func is
> executing. With lexical binding, x would be unbound in the body of
> some-func. (This assumes that x is not defined with defvar, naturally.)
Or, to put it another way, bindings only affect variable references that
are _physically_ (lexically) located within the binding form, whereas
dynamic bindings affect any code that's executed while the binding is
active, no matter where it is.
Note that lexical binding is _optional_ -- a source file has to have a
file header that turns it on, like:
;;; ... -*- lexical-binding: t -*-
As Kai says, variable defined via `defvar' will still be bound
dynamically, even in a source file that uses lexical binding.
It's also necessary, I think, to have another way for a source file to
declare that a particular name should be bound dynamically, because it's a
common elisp programming style to use a dynamic variable to pass values
around, with a variable that's not really global -- that is, not defined
via defvar, and indeed, with no global binding, and only bound using `let'.
Because such variables typically have names that are rather generic, it's
not reasonable to just suggest that they be defined using `defvar'.
Common-lisp uses `declare' to say that variables are special even when
they don't otherwise appear to be, but I'm not sure it's a good idea to
copy that, since elisp doesn't support any other uses of declare.
I thought that perhaps something like `defspecial' would be appropriate,
e.g., (defspecial foo) declares `foo' to be dynamically bound in the
current file (and only in the current file).
-Miles
--
Fast, small, soon; pick any 2.
- Re: Merging x*, w32* and mac* sources (was Re: table.el), (continued)
- Re: table.el, Miles Bader, 2001/12/01
- Re: table.el, Tak Ota, 2001/12/01
- Re: table.el, Tak Ota, 2001/12/01
- Re: table.el, Kai Großjohann, 2001/12/02
- Re: table.el,
Miles Bader <=
- Lexical bindings (was Re: table.el), Kim F. Storm, 2001/12/02
- Re: Lexical bindings (was Re: table.el), Kai Großjohann, 2001/12/02
- Re: Lexical bindings (was Re: table.el), Eli Zaretskii, 2001/12/02
- Re: Lexical bindings (was Re: table.el), Kim F. Storm, 2001/12/02
- Re: Lexical bindings (was Re: table.el), Stefan Monnier, 2001/12/02
- Re: Lexical bindings (was Re: table.el), Kim F. Storm, 2001/12/02
- Re: Lexical bindings (was Re: table.el), Miles Bader, 2001/12/02
- Re: Lexical bindings (was Re: table.el), Kim F. Storm, 2001/12/03
- Re: Lexical bindings (was Re: table.el), Miles Bader, 2001/12/03
- Re: Lexical bindings (was Re: table.el), Kim F. Storm, 2001/12/04