Macros (Was: Interesting: "Lisp as a competitive
advantage")
Keith Wansbrough
Keith.Wansbrough@cl.cam.ac.uk
Fri, 04 May 2001 16:52:14 +0100
Jerzy Karczmarczuk <karczma@info.unicaen.fr> writes:
> Macros in Scheme are used to unfold n-ary control structures such as COND
> into a hierarchy of IFs, etc. Nothing (in principle) to do with laziness
> or HO functions.
Isn't this exactly the reason that macros are less necessary in lazy languages?
In Haskell you can write
myIf True x y = x
myIf False x y = y
and then a function like
recip x = myIf (abs x < eps) 0 (1 / x)
works as expected. In Scheme,
(define myIf
(lambda (b x y)
(if b x y)))
does *not* have the desired behaviour! One can only write myIf using
macros, or by explicitly delaying the arguments.
--KW 8-)