From: Eric Cooper <ecc@cmu.edu>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Accessing constructors (tags) from C
Date: Sun, 23 Nov 2008 13:38:28 -0500 [thread overview]
Message-ID: <20081123183828.GB16898@localhost> (raw)
In-Reply-To: <49299F76.6090006@rice.edu>
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
next prev parent reply other threads:[~2008-11-23 18:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-23 18:22 Raj Bandyopadhyay
2008-11-23 18:38 ` Eric Cooper [this message]
2008-11-23 18:42 ` [Caml-list] " David Allsopp
2008-11-23 21:49 ` Mathias Kende
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081123183828.GB16898@localhost \
--to=ecc@cmu.edu \
--cc=caml-list@yquem.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).