3 ms·
> Another place where macros in Lisp fail is that they may evaluate an expression twice Strictly speaking, macros don't evaluate their expressions at all. Squ
by sjolsen 12y ago
> Another place where macros in Lisp fail is that they may evaluate an expression twice
Strictly speaking, macros don't evaluate their expressions at all.
Square is a bad example, though. Macros are not for writing function-like expressions; they're for extending (or more generally transforming) the syntax of the language. Inline functions and compiler macros are more appropriate tools for things like square.
- gus_massa 12y ago> Strictly speaking, macros don't evaluate their expressions at all. OK, you are right. A better example is a bad implementation of a short circuiting or: (define-syntax-rule (bad-or x y) (if x x y)) It can't be a function because sometimes you don't want to evaluate y, but in the resulting code x is sometimes executed twice.