[mercury-users] map__foldl2

Robert Bossy bossy at ccr.jussieu.fr
Sat Dec 18 06:55:59 AEDT 1999

> I think it would be a good idea to do different code in different
> modes using the purity delcarations.  So when you introduce a predicate
> with different code for different modes, it is by default impure.
> You need to promise that it is pure at some point.

Once, I used a workaround. It was a predicate that did quite the same thing
that prolog's var (and nonvar), the code was something like:

:- impure pred var(T).
:- mode var(in) is semidet.
:- mode var(unused) is semidet.

:- pragma c_code(var(Var::in),[will_not_call_mercury],"SUCCESS_INDICATOR = 0").

:- pragma c_code(var(Var::unused),[will_not_call_mercury],"SUCCESS_INDICATOR =

var(Var) will succeed if Var is free and fail if var is bound. It is declared
impure because these calls should not be reordered for optimisation. So the
predicates using var will be also impure (unless promised pure).


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