[mercury-users] Assert/Retract
Daniel Elenius
elenius at csl.sri.com
Fri Jan 27 12:57:31 AEDT 2006
Ralph Becket wrote:
> 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.
>
>
Sure, that would be great!
We are developing a "policy reasoner". Policies would be Mercury modules
(currently they are Prolog modules), and can be loaded on/unloaded from
the reasoner at runtime. Hence the (perceived) need for assert/retract.
Requests are sent to the reasoner in the form of lists of facts
(currently Prolog lists of Prolog atoms). The reasoner does
goal-directed search (normal Prolog query) over the loaded policies,
with the list of atoms as a parameter, and answers yes or no to the
requests.
There is also some clp(r) going on, but that's a separate issue...
Daniel
--------------------------------------------------------------------------
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