[mercury-users] Impurity annotations on modes?

Peter Schachte schachte at cs.mu.OZ.AU
Fri Jul 1 10:23:32 AEST 2005


On Thu, Jun 30, 2005 at 01:58:46PM +1000, Peter Hawkins wrote:
> Hi...
> 
> Is it possible for some modes of a predicate to be impure, but not others?
> In particular I would like to write this code:
> 
> :- func ask_var_value(constraint_variable) = value_type.
> :- impure mode ask_var_value(ia) = (out) is det.
> :- mode ask_var_value(in) = (out) is det.
> 
> (In other words, it's only impure to ask the value of a variable if it 
> isn't known to be ground)
> 
> Doable?

It's not clear that it's desirable.  This would mean that adding a new
mode for some library predicate somewhere could brake existing code,
because the mode analysis would allow a different scheduling of the
body that would then use an impure mode for a predicate where it
previously used a pure one.  This could probably be fixed by having
the mode analyzer avoid impure modes when the caller is not declared
impure, but that would require integrating mode and purity analysis,
which doesn't sound like a good idea, either.

Anyway, impurity is probably not the best way to hide state.

-- 
Peter Schachte              People with advantages are loath to believe that
schachte at cs.mu.OZ.AU        they just happen to be people with advantages.
www.cs.mu.oz.au/~schachte/      -- C. Wright Mills 
Phone: +61 3 8344 1338      
--------------------------------------------------------------------------
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