[mercury-users] lisp macros

Peter Schachte schachte at cs.mu.OZ.AU
Thu May 23 22:03:37 AEST 2002


> > does anyone have much experience
> > with lisp macros and what they add compared to programming in a language
> > like Mercury?
> 
> The Lisp macro facility was generally used for two purposes:
> (1) as a kind of programmer-driven inlining tool; and
> (2) to extend the "syntax" of the language to support things like Lisp's
> loop syntax.
> 
> (1) is something you can take or leave

Mostly agreed, though when you're building something that will be
really heavily used, it's nice to have control over optimization.

> (2) is a problem, because you can no longer look at code and assume you
> know what is function application and what isn't

I don't remember ever finding this a problem, and the benefits are
large.  If used judiciously, it's a very nice facility.

Think of it this way:  if you weren't working here, you could never
have implemented the state thread transformation, or the new @ syntax
for naming terms or the ^ accessor facility, or ....  In terms of
language elegance, I would argue that rather than being part of the
Mercury language, these features should live in libraries and be
defined as some kind of source to source translation.

FWIW, Prolog's term expansion facility is much more powerful than
Lisp's macros, especially if the Prolog implementation tolerates
transforming a clause into a list of clauses, and if it expands
end_of_file.  It's not elegant, but it is powerful.  All of the
Mercury features I named would be fairly easy to implement in Prolog
using term expansion.

-- 
Peter Schachte              Intellectual brilliance is no guarentee against
schachte at cs.mu.OZ.AU        being dead wrong.
www.cs.mu.oz.au/~schachte/      -- David Fasold 
Phone: +61 3 8344 9166      
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list