3 ms·
In Lisp the macro for a symbol, is called a symbol macro. Symbol macros are defined with DEFINE-SYMBOL-MACRO and SYMBOL-MACROLET. Functions defined in a file w
by lispm 10y ago
In Lisp the macro for a symbol, is called a symbol macro. Symbol macros are defined with DEFINE-SYMBOL-MACRO and SYMBOL-MACROLET.
Functions defined in a file where a macro is defined and used are also not seen by the file compiler. The use of (EVAL-WHEN (:COMPILE-TOPLEVEL) ...) instructs the file compiler to execute the enclosed forms at compile-time. Thus one can tell the compiler to define a function in the compile time environment or to load some code at compile time via LOAD or REQUIRE.
- felideon 10y agoInteresting. I haven't written much Lisp but I was under the impression DEFUN had some black magic that obviated the need for that.
- white-flame 10y agoCommon Lisp has a number of various namespaces that symbols can be defined in. Interfaces like DEFUN, DEFMACRO, and DEFINE-SYMBOL-MACRO all are explicit within their domain, and have explicit rules as to what is available when with respect to read/compile/evaluate times. Common Lisp is a very explicit language, and that explicitness allows macros to easily coexist with other code, because nothing is hidden by syntax or "black magic". (By default. Because you can morph the language to do nearly anything you'd want to.)