Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Automatic wrapper generator
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-05-18 (10:36)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] Automatic wrapper generator
On Tue, 2004-05-18 at 19:25, Olivier Andrieu wrote:
>  > Here's your chance to get THE LOT in one go.
> I really don't buy this. There is just not enough information in the C
> prototypes to give you a reasonable interface for OCaml.

You're right. It doesn't generate an interface
any more 'reasonable' than the C one it is wrapping.

>  Or does your
> generator use annotations (like camlIDL does) ?

Not at present, although that will be necessary.

> For instance, consider this prototype:
>   int foo (double *, int);

> Even if (double *, int) represents an array and its length, the caml
> interface is not obvious :
>   float array -> int -> ...   (straightforward mapping)
>   float array -> ...          (use the array length for the int parameter)
>   float array -> pos:int -> len:int -> ... (account for pointer arithmetic)

Yup. So what you actually get 'initially' is:

	c_double c_ptr -> c_int -> c_int

Not a single Ocaml native data type is visible.

[Well, we could typemap c_int to 'native_int' since they're
isomorphic by specification, and c_double to float for the same 
reason ..]

>In the end you get at best a very low-level bunch of autogenerated
> unsafe externals, that you have to re-wrap in ocaml to get something
> comfortable and/or safe to program with.

That is correct, that's what you get.

(1) It's better than nothing :)

(2) It can be used to build a better interface *in Ocaml*

(3) Once it works, it may be possible to add some annotations
to improve the level of abstraction of the generated interface

John Skaller,
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: