[m-users.] add rules at runtime

Julien Fischer jfischer at opturion.com
Tue Nov 6 16:41:35 AEDT 2018

Hi Jeff,

On Mon, 5 Nov 2018, Jeffrey Brown wrote:

> I want to write a program in Mercury that lets a user add (simple
> nonrecursive) rules at runtime, like "Bob knows Mary" or "eukaryotes
> use oxygen". Is it possible?

If you mean, is it possible to do it as in Prolog, using assert/1 and
retract/1 to modify the clause database, then no.  Mercury does not
support that.

In Mercury you would need to define your own data structures to hold the
rules added a runtime (or use some of the ones in the standard library.)

The section "Assert and retract" in the Prolog to Mercury transition
guide has further details.


More information about the users mailing list