3 ms·
It sometimes fun to take some random Lisp code and fully expand the macros: (macroexpand '(loop for x in list minimize (sin x))) The output depends on you
by pjscott 16y ago
It sometimes fun to take some random Lisp code and fully expand the macros:
(macroexpand '(loop for x in list minimize (sin x)))
The output depends on your Lisp compiler, but it can get pretty wild. This is why we have the macroexpand-1 function, to just expand the first macro it finds and stop before all collapses into madness.
A compiler writer could get a lot of mileage out of this sort of thing. For example, a LET special form could be implemented as a macro that expands to a call to an anonymous function. All the looping forms could be turned into lambdas and recursion. As long as the compiler can handle that sort of thing nicely, this could really simplify the compiler code.