[m-dev.] Suggestion for a new "where" operator

Ralph Becket rafe at cs.mu.OZ.AU
Mon Aug 4 15:25:51 AEST 2003


Peter Schachte, Monday,  4 August 2003:
> > The idea is that an expression (E where G) denotes the expression E
> > computed using the goal G.
> 
> Sounds like a great idea.
> 
> Suggestion:  make the precedence of 'where' higher (lower number) than
> '=', so you could write
> 
> 	f(X) = Y where ....
> 
> I think this is prettier than
> 
> 	f(X) = Y :- ....

I'm not sure that would be a good idea.

> The only problem with this is syntactic:  people will tend to write
> 
> 	X where p(X), q(X)
> 
> instead of
> 
> 	X where (p(X), q(X))
> 
> and no doubt the error message they get will not immediately help them
> realize the simple precedence problem.

I think this is a worse problem than prefering "where" to ":-".

Hmm, as it stands:

Op	Priority
--	--------
where	1175
;	1100
,	1000
=	 700

which means that one would have to write

	f(X) = (Y where p(X, Y)).

which isn't too bad.

Also, (X where p(X), q(X)) parses as (X where (p(X), q(X))) which is
what one would want.

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