[mercury-users] Binding variables in an if then else?

Peter Hawkins peter at hawkins.emu.id.au
Sat Aug 7 12:07:22 AEST 2004


Hi...

I seem to use this idiom quite a lot when writing mercury code:

Suppose we have a variable that we want to decompose or unify, say 
AList = [1,2,3]

I want to assign the values in AList to V1, V2, and V3, respectively.

( AList = [A1, A2, A3] ->
	V1 = A1,
	V2 = A2,
	V3 = A3
;
	throw("Something is wrong")
)

Is it possible to write this more compactly?

I really want to write:
AList = [V1, V2, V3]
in a deterministic context, and have an exception thrown on failure.

Perhaps non-local assignment in the head of an if-then-else could be permitted 
in the case where the 'else' case has an erroneous determinism?

=)
Peter
--------------------------------------------------------------------------
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