[m-users.] add rules at runtime

Aistis Raulinaitis sheganinans at gmail.com
Wed Nov 7 11:28:17 AEDT 2018


Jeff,

Another technique that is commonly overlooked is to compile a `fact_table`
into a dynamic library then using Mercury's runtime linking facilities to
swap out fact tables at runtime.

More info:
http://lists.mercurylang.org/archives/users/2002-April/001683.html

Aistis Raulinaitis


On Nov 6, 2018 06:37, "Jeffrey Brown" <jeffbrown.the at gmail.com> wrote:

Thanks! I had no idea I should read that.

What kind of data structure does Mercury itself use to represent rules? I'd
like to be able to search for information in any direction -- i.e., using
the terminology of maps, any member of any relationship could be treated as
a key or a value.

On Tue, Nov 6, 2018 at 12:41 AM Julien Fischer <jfischer at opturion.com>
wrote:

>
> 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.
>
> Julien.
>
>

-- 
Jeff Brown | Jeffrey Benjamin Brown
Website <https://msu.edu/~brown202/>   |   Facebook
<https://www.facebook.com/mejeff.younotjeff>   |   LinkedIn
<https://www.linkedin.com/in/jeffreybenjaminbrown>(spammy, so I often miss
messages here)   |   Github <https://github.com/jeffreybenjaminbrown>
_______________________________________________
users mailing list
users at lists.mercurylang.org
https://lists.mercurylang.org/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20181106/545c6627/attachment.html>


More information about the users mailing list