MACRO-FUNCTION(3cl) |
Common Lisp Reference |
MACRO-FUNCTION(3cl) |
NAME
macro-function – return macro expansion function (accessor)
SYNOPSIS
macro-function
&optional
|
ARGUMENTS and VALUES
—a symbol.
—an environment object.
nil. —a macro function, or
—a macro function.
DESCRIPTION
Determines whether has a function definition as a macro in the specified environment.
If so, the macro expansion function, a function of two arguments, is returned. If macro-function returns nil. has no function definition in the lexical environment , or its definition is not a macro,
It is possible for both macro-function and special-operator-p to return true of . The macro definition must be available for use by programs that understand only the standard Common Lisp special forms.
AFFECTED BY
(setf macro-function), defmacro, and macrolet.
EXCEPTIONAL SITUATIONS
The consequences are undefined if setf of macro-function. is non-nil in a use of
NOTES
setf can be used with macro-function to install a macro as a symbol’s global function definition:
(setf (macro-function ) )
The value installed must be a function that accepts two arguments, the entire macro call and an environment, and computes the expansion for that call. Performing this operation causes symbol to have only that macro definition as its global function definition; any previous definition, whether as a macro or as a function, is lost.
EXAMPLES
(
defmacro
(
)
’(
macro-function
’
))
(
not
(
macro-function
’
))
false
(macrolet (( (&environment )
(if (macro-function ’ )
``
``)))
(list ()
(macrolet (( () :))
())))
()
SEE ALSO
defmacro(3cl)
AUTHOR and COPYRIGHT
Substantial portions of this page are taken from draft proposed American National Standard for Information Systems—Programming Language—Common Lisp, X3J13/94-101R, Version 15.17R, Fri 12-Aug-1994 6:35pm EDT; no copyright indicated.
Additional clarification and comments by Michael Marking <marking@tatanka.com>, http://www.tatanka.com/software/cl-manpages/; alternatively, https://github.com/wakinyantanka/cl-manpages/. Copyright 2017 Michael Marking as both an original and a derivative work.
Licensed under Creative Commons Attribution-NoDerivatives 4.0 International (CC BY-ND 4.0).
This page last revised Sunday 26 February 2017.