[m-dev.] switches

Ian MacLarty maclarty at cs.mu.OZ.AU
Mon Aug 22 22:10:28 AEST 2005


Hello,

Would there be an issue with transforming code like the following:

p(X, Y) :-
	(
		(X = a ; X = b),
		q(X, Y)
	;
		(X = c ; X = d),
		r(X, Y)
	).

into the following:

p(X, Y) :-
	(
		X = a,
		q(X, Y)
	;
		X = b,
		q(X, Y)
	;
		X = c,
		r(X, Y)
	;
		X = d,
		r(X, Y)
	).

before switch detection?

The first form is more convenient, especially if there are multiple lines
of code in each disjunct, however I can't use the first form because the
compiler can't infer the body is det.

I'm asking because I've encountered this situation a number of times now in my
experiences with Mercury.

Ian.

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