Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] hash_variant anomalies
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <garrigue@k...>
Subject: Re: [Caml-list] hash_variant anomalies
> I guess the upshot of all this is that it's much easier to map
> polymorphic variants to C constants because there's no easy way to
> calculate the integer value of a normal variant without knowing it's
> position in the variant declaration.  The integer value of a
> polymorphic variant can be computed directly from its name alone.

Hard to say which is hardest: in both cases you must be careful to
synchronize your sources, and avoid typos. Polymorphic variants are
a bit stronger to ansynchronies, since they are by name.

> Overall I have to say writing ocaml-c interfaces is pretty easy.
> Mapping long lists of c enums and defines to ocaml variants seems to
> be one of the more tedious tasks.

Doesn't ocamlidl provide some help with standard variants?
For polymorphic variants, there is a tool called varcc in the lablgtk
distribution. There is no documentation, but examples and source code
should be informative enough. It generates efficient conversion tables
and macros between polymorphic variants and C enums.

Cheers,

Jacques Garrigue
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr