[m-dev.] Syntactic sugar for functor matching

Peter Schachte schachte at cs.mu.OZ.AU
Tue Nov 6 22:41:43 AEDT 2001


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

-- 
Peter Schachte              A classic is something that everybody wants to
schachte at cs.mu.OZ.AU        have read and nobody wants to read.
www.cs.mu.oz.au/~schachte/      -- Mark Twain 
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