[m-dev.] Syntactic sugar for functor matching
Simon Taylor
stayl at cs.mu.OZ.AU
Mon Nov 12 20:01:29 AEDT 2001
On 07-Nov-2001, Peter Schachte <schachte at cs.mu.OZ.AU> wrote:
> 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.
It's also a pain to have to change the way a clause is written when
you find you need to use the switched-on argument elsewhere.
> 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++.
> This proposal doesn't really solve any problem
> that a well placed comment couldn't solve.
How does a comment help? A comment would just add more verbosity.
There was general agreement at the Mercury meeting that this change
is worthwhile. Given that it's possible to just not use the new syntax
if you don't like it, I'll commit the change.
Simon.
--------------------------------------------------------------------------
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