[m-dev.] Adding default clauses to the language.

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Aug 9 17:20:44 AEST 2001


On 09-Aug-2001, Peter Schachte <schachte at cs.mu.OZ.AU> wrote:

> Hey, we could use "!" as the guard operator! :-b

Yeah, deja vu...

> Alright, I guess this just isn't going to work.  Bummer.
> 
> > You could probably give the version for functions a mode-independent
> > declarative semantics.
> 
> I wouldn't think so.  Aren't functions the same as predicates, aside from
> syntax and a default mode?

Yes, but syntax is important here; you could give a special role to the
function result, whereas giving a special role to the last argument of a
predicate is just too horrible to consider.

> Wouldn't 
> 
> f(1, 1) = q(1).
> f(2, 2) = 4.
> otherwise f(_, _) = 6.
> 
> have the same problem?

You could define the declarative semantics of that to be (the completion of)

	f(1, 1) = q(1).
	f(2, 2) = 2.
	f(A, B) = 6 :- \+(A=1, B=1, _=q(1)), \+(A=2, B=2, _=4).

Still, I hope no-one gets too encouraged by this ;-)

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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