pjstirling wrote:I'm quite sure you are wrong here, the special operators are the true primitives, they don't have anytthing below them. What the standard is talking about here is that the implementation needs to have an macro expander for the special operators which understands which parts of the code being compiled need to be macroexpanded in turn.
I'm not sure what you're trying to say here, but I assure you I'm not
Special operators don't need to have macro-expansions -- only non-standard special operators do, and not because the implementation needs to expand them (it doesn't -- that's what makes them special operators): that rule is just there to enable non-implementation code to understand them.
pjstirling wrote:MACROEXPAND and MACROEXPAND-1 both return two values: the expanded form, and a boolean saying whether the expansion changed the form. MACROEXPAND calls MACROEXPAND-1 on each subform, and checks this second value, if it is T then MACROEXPAND-1 is called again on the new expansion. This loops until the second value is nil (this is why macroexpansion always terminates eventually).
It
doesn't always terminate. MACROEXPAND doesn't call MACROEXPAND-1 on each subform, it just calls it on the form you give it (there's not a "macroexpand-fully" function in CL); and I think perhaps you're confused about what the second value means: it isn't NIL if the form merely looks the same, it's only NIL if the form isn't a macro form. If you define a macro that expands into itself -- e.g., (defmacro foo (x) `(foo ,x)) -- then (macroexpand-1 '(foo 42)) will return (foo 42) and T -- the first value looks the same as what you put in, but the second value is T, not NIL. (macroexpand '(foo 42)) will infloop, because it keeps doing MACROEXPAND-1 and getting the same result. It only stops if it eventually bottoms out in something that isn't a macro.