[mercury-users] hi & a feq queries

Donald Syme Donald.Syme at cl.cam.ac.uk
Wed Aug 19 07:26:37 AEST 1998


Re nesting of constructors in switches: thanks for your help.
The reference manual could be updated to reflect this.

The (small) problem that made me go check out the manual (and subsequently
led to my stupid question) was switch detection when existentials
guard the cases, e.g. :

:- module junk.
:- interface.
:- import_module list.
:- pred h(list(int) :: in, int :: out) is det.
:- implementation.

h(A,B) :- (A = [], B = 1 ; 
          (some [H,T] (A = [H|T], B = 2))).

I guess I only do this sort of thing in generated
code, and I can get around it by  lifting the "some" up above the 
switch (taking a union of all variables in all the patterns).

Thanks again,
Don







More information about the users mailing list