
On Thu, May 03, 2001 at 04:25:45PM -0400, Alan Bawden wrote:
Here's a macro I use in my Scheme code all the time. I write:
(assert (< x 3))
Which macro expands into:
(if (not (< x 3)) (assertion-failed '(< x 3)))
Where `assertion-failed' is a procedure that generates an appropriate error message. The problem being solved here is getting the asserted expression into that error message. I don't see how higher order functions or lazy evaluation could be used to write an `assert' that behaves like this.
This is a good example, which cannot be implemented in Haskell. "Exception.assert" is built in to the ghc compiler, rather than being defined within the language. On the other hand, the built in function gives you the source file and line number rather than the literal expression; the macro can't do the former. --Dylan Thurston dpt@math.harvard.edu