What can common lisp macros do that can't be done by a function that uses eval and gets quoted arguments?
Name:
Anonymous2009-10-25 7:09
What a shit explanation.
1) FEXPRs are fucking slow. Macros do the actual work, consing like there's no tomorrow and doing expensive stuff - generic function dispatch that comes with abstraction. They expand into code that doesn't even have to require the system containing the macro, thus reducing image bloat.
2) Macros can use lexical environments (and i'm not talking about environment objects, which in ANSI can't even be augmented or introspected upon. And not much except SBCL implements CLtL2 with their &env goodness. See how much hoops CL-WALKER has had to go through to do simple quasi-"portable" macroexpansion). Special variables by default sucks, as it:
- Fucks up referential transparency. Leads to spaghetti code clusterfuck.
- Is slow, as can't be reduced to register access.
- Compiler can't prove properties about the code, e.g. type inference if anything can be modified anywhere
Runtime-based lexical access is fucking slow - see Ruby (though Ruby sucks on many more levels). Runtime-modifiable lexical access sucks even moar - leads to spaghetti code like dynamic-by-default.
And in SBCL TLS indices don't get recycled. So don't plan on using PROG with uninterned symbols and expecting it to work still after using over 8192 uninternet symnols. Try: (loop repeat 8192 (prog (list (make-symbol "chuj dupa cyce")) '(42) nil). Untested as there's no REPL nearby.