[mercury-users] syntax across languages

Ralph Becket rafe at cs.mu.OZ.AU
Mon Jun 3 10:19:36 AEST 2002


Pixel, Sunday,  2 June 2002:
> Fergus Henderson <fjh at cs.mu.oz.au> writes:
> > 	Multiple selection: two different syntaxes.
> > 
> > 		(2) disjunctions:
> > 
> > 		( X = positive, ...
> > 		; X = negative, ...
> > 		; X = zero, ...
> > 		)
> 
> one thing i try to have for the "switch" entry, is that the val only
> appears once (syntactically).

It seems a small thing to worry about.  The Mercury term for a
disjunction where each arm is headed by a unification of a variable with
a different data constructor is `switch', precisely because of its
similarity to the C construct of the same name.

> this would be better in if_then_else where i give the n-ary
> if_then_else. The problem is I don't know if it would better with a
> comment telling the conditions must be separate, or writing explictly
> the cut

A Mercury switch is not the same as an if-then-else chain.  For a start,
behaviour depends on the mode.  Also (unless the right compiler flags are
given) the compiler is free to reorder the disjuncts.

> > 		(1) multiple clauses:
> > 
> > 		foo(positive) = ...
> > 		foo(negative) = ...
> > 		foo(zero) = ...
> 
> i'd prefer an anonymous solution. is there one?

This is it!  The variable being switched on isn't even mentioned, so in
that sense it's even more `anonymous' than the C version.

- Ralph
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list