[m-dev.] Syntactic sugar for functor matching
Simon Taylor
stayl at cs.mu.OZ.AU
Fri Nov 2 21:47:31 AEDT 2001
On 02-Nov-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 02-Nov-2001, Ralph Becket <rafe 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)) :- ...
> >
> > It's not clear to me that putting the pattern on the RHS of @ is
> > the right thing to do, but that's what ML, Haskell, etc. do.
>
> How about using `=' rather than `@',
I think the precedence of `=' is too low. In Haskell, `@' is
at one of the highest precendence levels.
It would also be potentially confusing with the proposed named
field syntax. If we aren't going to use different brackets for
the named field syntax, the main thing that will stand out is the
unifications in the arguments.
> and allowing either order?
The two sides of the `@' should be able to be arbitrary terms.
It doesn't make sense to impose an order.
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