[m-users.] calling mercury from swi-prolog

Julien Fischer jfischer at opturion.com
Thu Jul 4 13:27:32 AEST 2019


Hi Daniel,

On Wed, 3 Jul 2019, Daniel Gross wrote:

> I am playing with he thought to rewrite some predicates in swi-prolog
> in Mercury. This could allow me to work in a piece by piece manner, as
> I explore and learn more about Mercury.
> 
> Are there examples out there that show how this could be best done?

With SWI-Prolog specifically, not that I'm aware of.

> I guess, it would require exporting to C and then, somehow, wrapping
> that C into anĀ  external swi predicate ...

Based on a cursory glance at SWI-Prolog's foreign language interface
it should in principle be possible.

    1. Export the Mercury procedures to C
    2. Implement code in C to convert Mercury terms into Prolog ones.
    3. Wrap all of the above up using SWI-Prolog's foreign language
       interface into a library.
    4. Arrange for the Prolog system to load and initialise Mercury's
       runtime and standard libraries, and the library create in (3).

I wouldn't do that however; it seems like a terribly complicated way to
learn about Mercury.

Julien.


More information about the users mailing list