[m-users.] calling mercury from swi-prolog
Daniel Gross
grossd18 at gmail.com
Thu Jul 4 15:25:18 AEST 2019
Hi Julien,
Thank you.
*re: I wouldn't do that however; it seems like a terribly complicated way
tolearn about Mercury.*
Since I have a rather large Prolog code base, its not feasible to rewrite
it all in Mercury. Also, much of it wouldn't benefit from such a rewrite;
and some code can not be rewritten, as far as can tell, since it makes
extensive use of term_expansion pre-processing (essentially a Prolog based
Domain Specific Language - DSL).
There are however core areas where I am contemplating a rewrite in C++ --
and am now thinking that Mercury could be a better choice.
Btw, the idea to make it easy to porting small parts as needed is also
included in the Rust language, which makes it easy to interoperate with C++.
Daniel
On Thu, Jul 4, 2019 at 6:27 AM Julien Fischer <jfischer at opturion.com> wrote:
>
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20190704/44e3c0f3/attachment.html>
More information about the users
mailing list