[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
About Repeated Expansion
From: |
Xue Fuqiao |
Subject: |
About Repeated Expansion |
Date: |
Sun, 30 Dec 2012 14:30:07 +0800 |
The GNU Emacs Lisp
manual(http://www.gnu.org/software/emacs/manual/html_node/elisp/Repeated-Expansion.html#Repeated-Expansion)
says:
Here is an example of how such side effects can get you into trouble:
(defmacro empty-object ()
(list 'quote (cons nil nil)))
(defun initialize (condition)
(let ((object (empty-object)))
(if condition
(setcar object condition))
object))
If initialize is interpreted, a new list (nil) is constructed each time
initialize is called. Thus, no side effect survives between calls. If
initialize is compiled, then the macro empty-object is expanded during
compilation, producing a single “constant” (nil) that is reused and altered
each time initialize is called.
It says if `initialize' is compiled, the (nil) will be reused and altered each
time `initialize' is called. But there is no expression that alters
`empty-object', why will it be altered?
--
Best regards.
- About Repeated Expansion,
Xue Fuqiao <=
RE: About Repeated Expansion, Drew Adams, 2012/12/30