[mercury-users] Assert/Retract

Ralph Becket rafe at cs.mu.OZ.AU
Fri Jan 27 12:34:24 AEDT 2006


Daniel Elenius, Monday, 23 January 2006:
> Is it possible to assert/retract statements in Mercury? Mercury looks 
> like a very good fit for a project I'm doing, but I don't think I can 
> manage without those "meta" facilities. Also, can I create a list of 
> terms (atoms)?

Following Peter's response, you can achieve similar results using the
impure `mutables' facility recently added to Mercury (see "Module-local
mutable variables" in the Reference Manual).

However, in our experience it is *virtually always* better to write a
pure program than an impure one, even if that means passing around an
extra "state" parameter to your predicates.  Debugging and maintaining
impure code is invariably very painful.  Mutables are intended for
situations where there genuinely is no pure alternative (e.g., for the
efficient implementation of all-solutions predicates or for holding
constraint stores for CLP).

If you can give us an outline of your problem, we may be able to suggest
a good (pure) Mercury idiom that does away with the need for
assert/retract.

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