[m-dev.] for discussion: proposed additions to FFI

Julien Fischer juliensf at csse.unimelb.edu.au
Tue Jun 24 15:00:05 AEST 2008


On Tue, 24 Jun 2008, Ralph Becket wrote:

> Julien Fischer, Tuesday, 24 June 2008:
>>
>>
>>
>> On Tue, 24 Jun 2008, Ralph Becket wrote:
>>
>>> Julien Fischer, Monday, 23 June 2008:
>>>>
>>>> This proposal extends the FFI with three new pragmas that allow for the
>>>> construction, deconstruction and testing of individual discriminated union
>>>> data constructors in foreign language code.
>>>
>>> I think this is a reasonable idea, although I wonder whether in
>>> practice you're almost always going to want all three operations
>>> (cons/decons/test), which might mean having a single pragma to generate
>>> all three would be better.
>>
>> How about listing the desired operations in a single pragma, something
>> like:
>>
>> 	:- pragma foreign_export_du_op("C", maybe, yes,
>> 		[test("TEST_yes"), cons("MAKE_yes"),
>> 		decons("UNAKE_yes")]).
>
> I'll raise you a level:
>
> 	:- pragma foreign_export_du_op("C", maybe,
> 		[yes - [test("TEST_yes"), cons("MAKE_yes"),
> 			decons("UNAKE_yes")],
> 		 no - [test("TEST_no")]]).

Snap!?

I'm not crazy about the nested lists, but it looks good aside from that.
Mark was saying that it might also be useful to have access to
individual fields as well.

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



More information about the developers mailing list