Contents    Page-10    Prev    Next    Page+10    Index   

Macros

A macro is a function from code to code, usually turning a short piece of code into a longer code sequence.

Lisp macros produce Lisp code as output; this code is executed or compiled.


(defun neq (x y) (not (eq x y)))

(defmacro neq (x y) (list 'not (list 'eq x y)))

(defmacro neq (x y) `(not (eq ,x ,y)))

In C, #define name pattern specifies a textual substitution. If pattern contains an operation, it should be parenthesized.


#define sum  x + y        /* needs parens */

   z = sum * sum;