[m-dev.] interpreting C datastructures as Mercury terms

Fergus Henderson fjh at cs.mu.OZ.AU
Thu May 7 16:47:01 AEST 1998


On 07-May-1998, Peter Schachte <pets at students.cs.mu.oz.au> wrote:
> Hmmmm.  I just had another thought.  Why can't you do what you want right
> now by defining an abstract type and defining different modes of constructor
> functions as pragma C code?  Should be simple enough.  Then it'll look to
> the user pretty much like an ordinary discriminated union type, even though
> it isn't implemented that way.

Generally that works OK, but there are two problems:

	(1) defining all those constructor functions is tedious
	    and should be automated

	(2) it still doesn't work for io__write, io__read and friends
	    (which is in fact exactly what Tom wanted it for in this
	    case)

Regarding (1), we should implement something like Mercury support
for SWIG (the SoftWare Interface Generator) or do as the Haskell
people are doing and go with something like CORBA or IDL, again
providing some automated way of generating a Mercury binding from
a CORBA or IDL spec.

Regarding (2), we should have builtin type classes
called say `constructable(T)' and `deconstructable(T)'
which ordinary types are automatically instances of;
for types definined in C, it should be possible to make
them instances of these type classes using appropriate
instance declarations.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.



More information about the developers mailing list