Re: Haskell-Cafe digest, Vol 1 #122 - 3 msgs

Subject: Re: Interesting: "Lisp as a competitive advantage"
Date: Thu, 03 May 2001 10:16:37 -0400
From: Norman Ramsey

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

(if (not (< x 3)) (assertion-failed '(< x 3)))
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.
Yeah, it's a good example, but are there any other uses for such quoting? If not, then implementing it as a builtin is perfectly adequate. (Not trying to pick on Lisp; Lisp is great. Just hoping for more examples.) | Dan Knapp, Knight of the Random Seed | http://brain.mics.net/~dankna/ | ONES WHO DOES NOT HAVE TRIFORCE CAN'T GO IN.

Hello! On Thu, May 03, 2001 at 06:09:01PM -0500, Dan Knapp wrote:
[...]
Yeah, it's a good example, but are there any other uses for such quoting? If not, then implementing it as a builtin is perfectly adequate. (Not trying to pick on Lisp; Lisp is great. Just hoping for more examples.)
IMHO you can do all the things you'd do with separate preprocessing steps for other languages with Lisp macros, inclusing scanner/parser generating for some example. Or you could do the analogous thing to camlp4 in Lisp with Lisp's own standard features (reader macros + normal macros). You can e.g. also emulate Emacs Lisp in Common Lisp by slightly hacking up the readtable and defining a few macros and functions into a separate package. That's quite easy, in fact, the more complicated part would be offering all those primitive functions of Emacs Lisp, but if you had this, you could compile all those Emacs Lisp packages into fast code. Imagine GNUs *not* crawling like a snail on a Pentium 200 *g* Kind regards, Hannah.
participants (4)
-
Alan Bawden
-
Dan Knapp
-
Dylan Thurston
-
Hannah Schroeter