[m-dev.] Syntactic sugar for functor matching
Simon Taylor
stayl at cs.mu.OZ.AU
Tue Nov 6 22:56:40 AEDT 2001
On 06-Nov-2001, Peter Schachte <schachte at cs.mu.OZ.AU> wrote:
> > A related proposal is to allow `X @ f(...)' to denote pattern matching
> > with f(...) and having X unify with that argument on success.
> >
> > For example, rather than writing
> >
> > p(f(A, B, C)) :- X = f(A, B, C), ...
> >
> > 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.
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