[m-dev.] Syntactic sugar for functor matching
Peter Schachte
schachte at cs.mu.OZ.AU
Wed Nov 7 12:33:05 AEDT 2001
On Tue, Nov 06, 2001 at 10:56:40PM +1100, Simon Taylor wrote:
> > > one could write
> > >
> > > p(X @ f(A, B, C)) :- ...
> >
> > Um, not to be stupid, but what's wrong with
> >
> > p(X) :- X = f(A, B, C), ...
> >
> > It's barely any more verbose, already legal, and requires no new syntax.
> > Mercury doesn't even have Prolog's only-clauses-are-indexed flaw to motivate
> > this sort of feature.
>
> Readability. If the functor is in the clause head it makes it
> clearer what is being indexed on and which case is being handled
> in the clause.
IMHO the benefit is not great enough to warrant adding more syntactic cruft
to the language.
I think we should be a bit more conservative about making syntactic
extensions, lest the langauge start to look like PL/I or C++. Named
arguments seems like a good idea because it's a lot more useful than just
solving the
p(f(_,_,_,_), ...)
underscore counting problem. This proposal doesn't really solve any problem
that a well placed comment couldn't solve.
--
Peter Schachte Free trade is the weapon of the strong,
schachte at cs.mu.OZ.AU protectionism is the shield of the weak.
www.cs.mu.oz.au/~schachte/ -- William Kaiser
Phone: +61 3 8344 9166
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list