Macros (Was: Interesting: "Lisp as a competitive advantage")

Fergus Henderson fjh@cs.mu.oz.au
Sun, 6 May 2001 00:53:24 +1000


On 04-May-2001, Marcin 'Qrczak' Kowalczyk <qrczak@knm.org.pl> wrote:
> Jerzy Karczmarczuk <karczma@info.unicaen.fr> pisze:
> 
> > In Clean there are macros. They are rather infrequently used...
> 
> I think they roughly correspond to inline functions in Haskell.
> 
> They are separate in Clean because module interfaces are written
> by hand, so the user can include something to be expanded inline in
> other modules by making it a macro.
>
> In Haskell module interfaces are generated by the compiler, so they
> can contain unfoldings of functions worth inlining without explicit
> distinguishing in the source.

I don't think that Clean's module syntax is the reason.
(Or if it is the reason, then it is not a _good_ reason.)
After all, compilers for other languages where module interfaces
are explicitly written by the programmer, e.g. Ada and Mercury, are
still capable of performing intermodule inlining and other intermodule
optimizations if requested.

My guess is that the reason for having macros as a separate construct
is that there is a difference in operational semantics, specifically
with respect to lazyness, between macros and variable bindings.

However, this is just a guess; I don't know Clean very well.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.