From: Jean Yang <jeanyang@csail.mit.edu>
To: caml-list@yquem.inria.fr
Subject: OCaml/C variant representation
Date: Wed, 24 Feb 2010 10:26:22 -0500 [thread overview]
Message-ID: <1bd843011002240726u6f0c3b87m7d58ab6415ea21ba@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 881 bytes --]
Hello,
I'm having some trouble with variant representation in the OCaml/C
interface.
According to the reference I found (
http://caml.inria.fr/pub/docs/manual-ocaml/manual032.html), it seems like if
we have value v = variant VConstr(val), where val is some integer value,
should have Field(val, 0) == hash_variant("VConstr") and Int_val(Field(v, 0)
== val. I don't seem to be understanding this correctly, since I am getting
Int_val(Field(v, 0)) == val.
I have the following datatype declaration in my OCaml:
type newty = VConstr of int | ...
In the C implementation of OCaml function foo : newty -> int, I have
something like this;
CAMLprim value foo (value v) { ... }
In the body of this function I am looking at the fields of val. Am I doing
something wrong here?
Thanks,
Jean
--
Jean Yang
http://people.csail.mit.edu/jeanyang
Save us! Think before you print.
[-- Attachment #2: Type: text/html, Size: 1101 bytes --]
next reply other threads:[~2010-02-24 15:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-24 15:26 Jean Yang [this message]
2010-02-24 16:42 ` Sylvain Le Gall
2010-02-28 15:16 ` [Caml-list] " Jianzhou Zhao
2010-02-28 16:22 ` Sylvain Le Gall
2010-02-24 23:07 ` [Caml-list] " Richard Jones
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=1bd843011002240726u6f0c3b87m7d58ab6415ea21ba@mail.gmail.com \
--to=jeanyang@csail.mit.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