diff options
| author | Noam Postavsky | 2016-06-24 20:39:24 -0400 |
|---|---|---|
| committer | Noam Postavsky | 2016-07-01 00:02:48 -0400 |
| commit | 850ba444a7be542c8dc92efbeb4031868f3f779d (patch) | |
| tree | aee964c7047f4fdcf0557a61548988d72bcadd1a /doc | |
| parent | f981b3136742a8597674dd4915afeb1b220a0464 (diff) | |
| download | emacs-850ba444a7be542c8dc92efbeb4031868f3f779d.tar.gz emacs-850ba444a7be542c8dc92efbeb4031868f3f779d.zip | |
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...".
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/lispref/variables.texi | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi index 6c53e9b6cca..a2d64815d94 100644 --- a/doc/lispref/variables.texi +++ b/doc/lispref/variables.texi | |||
| @@ -974,7 +974,7 @@ itself. | |||
| 974 | 974 | ||
| 975 | @cindex lexical environment | 975 | @cindex lexical environment |
| 976 | Here is how lexical binding works. Each binding construct defines a | 976 | Here is how lexical binding works. Each binding construct defines a |
| 977 | @dfn{lexical environment}, specifying the symbols that are bound | 977 | @dfn{lexical environment}, specifying the variables that are bound |
| 978 | within the construct and their local values. When the Lisp evaluator | 978 | within the construct and their local values. When the Lisp evaluator |
| 979 | wants the current value of a variable, it looks first in the lexical | 979 | wants the current value of a variable, it looks first in the lexical |
| 980 | environment; if the variable is not specified in there, it looks in | 980 | 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 | |||
| 1032 | time we evaluate the closure, it increments @code{x}, using the | 1032 | time we evaluate the closure, it increments @code{x}, using the |
| 1033 | binding of @code{x} in that lexical environment. | 1033 | binding of @code{x} in that lexical environment. |
| 1034 | 1034 | ||
| 1035 | Note that functions like @code{symbol-value}, @code{boundp}, and | 1035 | Note that unlike dynamic variables which are tied to the symbol |
| 1036 | @code{set} only retrieve or modify a variable's dynamic binding | 1036 | object itself, the relationship between lexical variables and symbols |
| 1037 | (i.e., the contents of its symbol's value cell). Also, the code in | 1037 | is only present in the interpreter (or compiler). Therefore, |
| 1038 | the body of a @code{defun} or @code{defmacro} cannot refer to | 1038 | functions which take a symbol argument (like @code{symbol-value}, |
| 1039 | surrounding lexical variables. | 1039 | @code{boundp}, and @code{set}) can only retrieve or modify a |
| 1040 | variable's dynamic binding (i.e., the contents of its symbol's value | ||
| 1041 | cell). | ||
| 1040 | 1042 | ||
| 1041 | @node Using Lexical Binding | 1043 | @node Using Lexical Binding |
| 1042 | @subsection Using Lexical Binding | 1044 | @subsection Using Lexical Binding |