[mercury-users] Re: lisp macros

Ralph Becket rafe at cs.mu.OZ.AU
Tue Jun 4 13:49:38 AEST 2002


Milan Zamazal, Monday,  3 June 2002:
> >>>>> "RB" == Ralph Becket <rafe at cs.mu.OZ.AU> writes:
> 
>     RB> I used to hack a lot of Lisp; I don't miss the macro facility.
> 
>     RB> The Lisp macro facility was generally used for two purposes:
>     RB> (1) as a kind of programmer-driven inlining tool; and
>     RB> (2) to extend the "syntax" of the language to support things like 
>     RB> Lisp's loop syntax.
> 
> One of the reasons why I moved from Prolog to Lisp instead of Mercury at
> some time was Mercury's syntax.  In my personal taste it's terrible,
> making the language quite unreadable, mostly resembling Perl.  Starting
> from the real stupidities inherited from Prolog (e.g. `term(...' versus
> `operator (...'), going through the annoyances implied by using an infix
> syntax, and finishing with the impossibility to define readable loop
> constructs.

I prefer infix notation.  It often allows for more concise code.

It is true that Mercury syntax is not as lightweight as one would wish,
but I don't believe that commas and parentheses are the problem (we've
experimented with taking them out, but observed little improvement, if
any, in terms of readability.)

Things that could do with improvement/adding (roughly in order):

* lighter higher order syntax
  - in general,
  - implicit modes,
  - clausal form lambdas;

* support for local declarations and definitions (currently we have
  slightly different syntax for the top-level and local definitions viz
  unifications);

* support for the monadic programming style;

* good looping constructs (sequence quantification);

* expressions evaluated via predicates
  (e.g. (PosRt where sqrt(X, _NegRt, PosRt))).

> Still, even if it's a separate programming language, I'd be more
> interested in it, if some (macro?) facility allowed me to fix the syntax
> myself (I don't think it's likely the current overall Mercury syntax
> will be ever changed).  I thought once about defining my own Lisp-like
> Mercury syntax and writing a preprocessor transforming it into the real
> Mercury syntax, but I've found it quite impractical for more reasons.

I would have thought a Lisp -> Prolog syntax translation would be
trivial.

I believe the reason Lisp's macro facility has had such success is that
to a first order approximation Lisp has no syntax to speak of.

If we are to preserve a more structured syntax then the macro facility
would be correspondingly more complex, unless you want to write these
things at the level of raw term to term transformations.

- Ralph
--------------------------------------------------------------------------
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