[mercury-users] Simple problem with switch

Ralph Becket rbeck at microsoft.com
Sat Sep 23 03:22:17 AEDT 2000


I got bitten by this one recently too.  The problem is that the compiler
only looks so far when searching for switches.  Here, your predicates
are deterministic, but the compiler can't verify that in both cases.

It's slightly odd and I suspect it's something to do with the fact that
tutu/1 has no output while tata/2 does.

If you recode tata/2 as

tata(T, I) :-
	(	T = a, I = 0
	;	T = b, I = 0
	;	T = c, I = 1
	;	T = d, I = 2
	).

then you should have no problems.  I would like to see the compiler
have a stab at spotting this style of switch since it's often the
case that several branches carry the same code.

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