[mercury-users] passing user-defined types between Mercury and C
Fergus Henderson
fjh at cs.mu.OZ.AU
Tue May 22 21:24:34 AEST 2001
Terrence Brannon <princepawn at earthlink.net> wrote:
> Says the manual:
>
> Mercury types are converted to C types according to the rules in
> section Passing data to and from C.
>
> I looked at that section, but it didn't say or give examples on how to
> pass and return user-defined datatypes.
That section says:
| Mercury variables of any other type are passed
| as a `MR_Word', which in the current implementation is a typedef for an
| unsigned type whose size is the same size as a pointer. (Note: ...)
Mercury variables with user-defined types should be treated as
abstract data types when you are accessing them from C.
You should treat `MR_Word' as an opaque type. Any operations that you
want to perform on the Mercury type should be done in Mercury code.
If you want to construct or deconstruct the type from C code, then you
should write Mercury procedures to do the construction or deconstruction
and export them to C (using `pragma export').
P.S. Terrance, your computer's clock is not set correctly, if the "Date:"
field in your email is any indication.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list