macro expansion time, reflects all the arguments supplied to the macro,
as if it had been declared with a single &rest argument.
- &environment specifies local semantics for various macros for use within
- the expansion of BODY. See the ENVIRONMENT argument to `macroexpand'.
+ &environment allows access to the macro environment at the time of
+ expansion; it is most relevant when it's necessary to force macro expansion
+ of the body of a form at the time of macro expansion of its top level.
+ &environment is followed by variable name, and this variable will be bound
+ to the value of the macro environment within BODY. See the ENVIRONMENT
+ argument to `macroexpand'.
-- The macro arg list syntax allows for \"destructuring\" -- see also
`destructuring-bind', which destructures exactly like `defmacro*', and
;; as such it can eliminate it if that's appropriate:
(put (cdar cl-active-block-names) 'cl-block-name name)
`(catch ',(cdar cl-active-block-names)
+ ;; Can't use &environment, since #'block is used in
+ ;; #'cl-transform-lambda.
,(cl-macroexpand-all body byte-compile-macro-environment))))
-(defmacro* macrolet ((&rest macros) &body form)
+(defmacro* macrolet ((&rest macros) &body form)
"Make temporary macro definitions.
This is like `flet', but for macros instead of functions."
(cl-macroexpand-all (cons 'progn form)
(list* name 'lambda (cdr (cl-transform-lambda details
-(defmacro* symbol-macrolet ((&rest symbol-macros) &body form)
+(defmacro* symbol-macrolet ((&rest symbol-macros) &body form)
"Make temporary symbol macro definitions.
Elements in SYMBOL-MACROS look like (NAME EXPANSION).
Within the body FORMs, a reference to NAME is replaced with its EXPANSION,
for (name expansion) in symbol-macros
do (check-type name symbol)
collect (list (eq-hash name) expansion))
(defvar cl-closure-vars nil)
-(defmacro lexical-let (bindings &rest body)
+(defmacro lexical-let (bindings &rest body)
"Like `let', but lexically scoped.
The main visible difference is that lambdas inside BODY will create
lexical closures as in Common Lisp."
(list '(defun . cl-defun-expander))
(if (not (get (car (last cl-closure-vars)) 'used))
(list 'let (mapcar #'(lambda (x) (list (caddr x) (cadr x))) vars)
(sublis (mapcar #'(lambda (x)
-(defmacro labels (bindings &rest body)
+(defmacro labels (bindings &rest body)
"Make temporary function bindings.
This is like `flet', except the bindings are lexical instead of dynamic.
;; XEmacs; the byte-compiler has a much better implementation of `labels'
;; in `byte-compile-initial-macro-environment' that is used in compiled
- (let ((vars nil) (sets nil)
- (byte-compile-macro-environment byte-compile-macro-environment))
+ (let ((vars nil) (sets nil))
(push (list (car (pop bindings)) 'lambda '(&rest cl-labels-args)
(list 'list* '(quote funcall) (list 'quote var)
- (cl-macroexpand-all (list* 'lexical-let vars (cons (cons 'setq sets) body))
+ (cl-macroexpand-all `(lexical-let ,vars (setq ,@sets) ,@body) env)))
(defmacro flet (functions &rest form)