Buy the book!
|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]||[Top]||[Contents]||[Index]||[ ? ]|
Extent refers to the time during program execution that a variable name is valid. In Emacs Lisp, a variable is valid only while the form that bound it is executing. This is called dynamic extent. "Local" or "automatic" variables in most languages, including C and Pascal, have dynamic extent.
One alternative to dynamic extent is indefinite extent. This means that a variable binding can live on past the exit from the form that made the binding. Common Lisp and Scheme, for example, support this, but Emacs Lisp does not.
To illustrate this, the function below,
make-add, returns a
function that purports to add n to its own argument m. This
would work in Common Lisp, but it does not do the job in Emacs Lisp,
because after the call to
make-add exits, the variable
is no longer bound to the actual argument 2.
(defun make-add (n) (function (lambda (m) (+ n m)))) ; Return a function. => make-add (fset 'add2 (make-add 2)) ; Define function
Some Lisp dialects have "closures", objects that are like functions but record additional variable bindings. Emacs Lisp does not have closures.
|webmaster donations bookstore||delorie software privacy|
|Copyright © 2003 by The Free Software Foundation||Updated Jun 2003|