mirror of
https://github.com/masscollaborationlabs/emacs.git
synced 2025-07-16 17:00:06 +00:00
Clarify lexical binding with symbol args behavior
* doc/lispref/variables.texi (Lexical Binding): Clarify that symbol
arguments always refer to dynamic values (Bug #23781). Remove mention
of obsolete restriction regarding lexical binding for defun and
defmacro, this no longer applies since 61b108cc
2012-05-29 "*
lisp/emacs-lisp/byte-run.el (defmacro, defun): Move from C...".
This commit is contained in:
parent
f981b31367
commit
850ba444a7
1 changed files with 8 additions and 6 deletions
|
@ -974,7 +974,7 @@ itself.
|
||||||
|
|
||||||
@cindex lexical environment
|
@cindex lexical environment
|
||||||
Here is how lexical binding works. Each binding construct defines a
|
Here is how lexical binding works. Each binding construct defines a
|
||||||
@dfn{lexical environment}, specifying the symbols that are bound
|
@dfn{lexical environment}, specifying the variables that are bound
|
||||||
within the construct and their local values. When the Lisp evaluator
|
within the construct and their local values. When the Lisp evaluator
|
||||||
wants the current value of a variable, it looks first in the lexical
|
wants the current value of a variable, it looks first in the lexical
|
||||||
environment; if the variable is not specified in there, it looks in
|
environment; if the variable is not specified in there, it looks in
|
||||||
|
@ -1032,11 +1032,13 @@ lives on even after the @code{let} binding construct has exited. Each
|
||||||
time we evaluate the closure, it increments @code{x}, using the
|
time we evaluate the closure, it increments @code{x}, using the
|
||||||
binding of @code{x} in that lexical environment.
|
binding of @code{x} in that lexical environment.
|
||||||
|
|
||||||
Note that functions like @code{symbol-value}, @code{boundp}, and
|
Note that unlike dynamic variables which are tied to the symbol
|
||||||
@code{set} only retrieve or modify a variable's dynamic binding
|
object itself, the relationship between lexical variables and symbols
|
||||||
(i.e., the contents of its symbol's value cell). Also, the code in
|
is only present in the interpreter (or compiler). Therefore,
|
||||||
the body of a @code{defun} or @code{defmacro} cannot refer to
|
functions which take a symbol argument (like @code{symbol-value},
|
||||||
surrounding lexical variables.
|
@code{boundp}, and @code{set}) can only retrieve or modify a
|
||||||
|
variable's dynamic binding (i.e., the contents of its symbol's value
|
||||||
|
cell).
|
||||||
|
|
||||||
@node Using Lexical Binding
|
@node Using Lexical Binding
|
||||||
@subsection Using Lexical Binding
|
@subsection Using Lexical Binding
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue