[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Eric Cooper <ecc@c...> |
| Subject: | Re: [Caml-list] Accessing constructors (tags) from C |
On Sun, Nov 23, 2008 at 01:22:46PM -0500, Raj Bandyopadhyay wrote:
> I was wondering how to access constructors from C.
See http://caml.inria.fr/pub/docs/manual-ocaml/manual032.html,
in particular, section 18.3.
> For example if I define a type
>
> type t = Null | Int of int
>
> and I want to create values of type t in C using the OCaml-C
> interface, how do I find the integers corresponding to constructors
> Null or Int?
This falls under the section "Concrete types", where it says:
The constant constructors and the non-constant constructors for a
given concrete type are numbered separately, starting from 0, in
the order in which they appear in the concrete type declaration.
> I would like to do this for a large OCaml program with lots of
> different types etc.
That will get tedious and error-prone. I'd look into using an
interface description language and stub compiler, like camlidl or
ocamlrpcgen.
--
Eric Cooper e c c @ c m u . e d u