[mercury-users] Working with exported types

Peter Moulder Peter.Moulder at infotech.monash.edu.au
Thu Jul 27 21:11:46 AEST 2006


On Thu, Jul 27, 2006 at 04:51:09PM +1000, Peter Wang wrote:

> Does it?  I'm interested in importing C constants *into* Mercury,
> without going through the contortions you've gone through in the OpenGL
> binding.  At the moment the easiest way to do that is to hard-code the
> value into the Mercury code, but that's brittle.

If interfacing with an existing C/C++ library that has an enum, then one
option to consider is to add a Mercury target to SWIG (http://www.swig.org/).
Swig already supports 13 target languages (including ocaml, excluding
haskell, goedel or any other purish language that I can recognize --
there are a couple of languages I haven't heard of).

This approach may take care of more of the problem of interfacing to
existing foreign code -- of which enum maintenance is a tiny part.

Someone once said "interfacing to foreign code from Mercury is easy, you
just add a wrapper function for each foreign function you need to call";
but "each function you need to call" can be a large number, and Mercury
has very few bindings to other languages.

I realize that making a natural binding for an imperative language can't
be completely automated, but even automating just part of it would still
be helpful when wrapping a large existing library, and in some cases one
is content with an un-idiomatic binding (passing !IO everywhere).

pjrm.
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the users mailing list