[mercury-users] C FFI for discriminated union types.

Guillaume Yziquel guillaume.yziquel at citycable.ch
Sun Jun 19 19:35:02 AEST 2011


Hi.

First of all, thank you for the detailed answers you provided so far to
my questions concerning Mercury.

I am now concerned with the C foreign function interface, most notably
concerning discriminated union types. I currently have the following
type declaration:

	:- type term_def --->
		term_def(term)		;
		term_def_string(str)	.

And I am passing back values of this type to C code, and would ideally
like to map them to an OCaml algebraic datatype. So I'd like to do the
conversion in my C stub code.

However, everything seems to be an MR_Word, and there isn't much
structural type information for such discriminated datatypes available
on the C side. So how should I deconstruct them? The reference guide is
fairly explicit for C# and such, but not for C...

-- 
     Guillaume Yziquel
--------------------------------------------------------------------------
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