Macros Ordinary functions 1. Evaluate the arguments 2. Apply function to (values of) the arguments 3. Return the result of step 2 Macros 1. Substitute the (unevaluated) args textually in the body 2. Evaluate the result 3. Return the result of step 2.
class special form macro (macro (params) pre-body) 1. The pre-body is evaluated twice : once to do the textual substitution and once to compute the value. 2. The first evaluation is done in the environment of the closure, the second is done in the environment of the call.
Want (inc! z) to expand to (set! z (inc z)) (define (inc! ) (macro (x) (list 'set! x (list 'inc x))))