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

Peter Schachte schachte at cs.mu.OZ.AU
Tue Aug 5 13:05:31 AEST 2003


On Tue, Aug 05, 2003 at 11:58:50AM +1000, Fergus Henderson wrote:
> This determinism requirement is necessary for consistency with the way
> we treat functions.  Unfortunately, however, it will make the proposal
> a bit more difficult to implement.  In particular, we will need to keep
> track in the HLDS of which goals came from a `where' expression, so that
> determinism analysis can check their determinism.
> 
> That in turn also means that we should not allow mode reordering to
> break up where expressions.

Maybe the best way to ensure consistency of the 'where' syntax with
function application would be to transform

	(E where G)

into

	f(vars)

where f is defined as

	f(vars) = E :- G

and vars = the intersection of the sets of variables appearing in the
clause outside the where expression and the variables appearing in
either E or G.  And the compiler should be encouraged to inline f.


BTW, just to be clear on this, I'm assuming in in (E where G), E is an
expression, not a variable.  So eg, I could write

	Avg = (Sum/Count where sum_count(List, Sum, Count))


-- 
Peter Schachte              Algorithms are inherently mathematical things that
schachte at cs.mu.OZ.AU        should be as un-patentable as the value of pi.
www.cs.mu.oz.au/~schachte/      -- Donald Knuth 
Phone: +61 3 8344 1338      
--------------------------------------------------------------------------
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