Hello everyone,
I am wondering how defmacro in common lisp is implemented with just defun. I ask this because I am trying to implement some metaprogramming into AutoLISP which does not have defmacro. Thanks
Albert
defmacro
Re: defmacro
A common-lisp macro (automated code rewriting) is much different than an autolisp macro (stored user actions).
Macro expansion happens between parsing and compilation/evaluation. If you have a language without sufficient macros, you must find some way to leverage or sit between the existing parser and compiler. In many languages, that means writing your own parser, implementing your own macro expansion, and writing out the processed text for the target system to read directly.
Macro expansion happens between parsing and compilation/evaluation. If you have a language without sufficient macros, you must find some way to leverage or sit between the existing parser and compiler. In many languages, that means writing your own parser, implementing your own macro expansion, and writing out the processed text for the target system to read directly.
-
- Posts: 16
- Joined: Fri Oct 17, 2008 12:27 pm
Re: defmacro
The short answer is that common lisp does not define defmacro in terms of defun, it is acutally just the opposite, defun is a macro that can be implemented using defmacro.
In common lisp defmacro is also a macro, that utilizes the ability of common lisp to treat code as data and vice versa, but without this property built into the language you can't create new language constructs (such as defun, defmacro, defclass, defmethod etc.) I don't believe that autolisp supports macros (code as data etc.).
In common lisp defmacro is also a macro, that utilizes the ability of common lisp to treat code as data and vice versa, but without this property built into the language you can't create new language constructs (such as defun, defmacro, defclass, defmethod etc.) I don't believe that autolisp supports macros (code as data etc.).
Re: defmacro
In CL, macro-function is actually setf-able, if you're feeling silly.