4 ms·
Unlike call-by-need evaluation, macros provide the opportunity to compute things at compile time (think lookup tables) or analyze the arguments at compile time
by reikonomusha 4y ago
Unlike call-by-need evaluation, macros provide the opportunity to compute things at compile time (think lookup tables) or analyze the arguments at compile time (think DB query syntax checking).
In Lisp, you can also define branching and looping as functions, but you need to concede and have the arguments themselves be (lambda) functions.
(defun while (c body)
(when (funcall c)
(funcall body)
(while c body)))
- eru 4y agoYes, I know that laziness doesn't take care of all macros. That's why even Haskell has macros. Yes, if you wrap your arguments in lambdas, you can write loops like that. Though to be as performant as the built-in constructs, you need a rather clever compiler that 'removes' the lambdas again.