caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* OCaml/C variant representation
@ 2010-02-24 15:26 Jean Yang
  2010-02-24 16:42 ` Sylvain Le Gall
  2010-02-24 23:07 ` [Caml-list] " Richard Jones
  0 siblings, 2 replies; 5+ messages in thread
From: Jean Yang @ 2010-02-24 15:26 UTC (permalink / raw)
  To: caml-list

[-- 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 --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-02-28 16:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-24 15:26 OCaml/C variant representation Jean Yang
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

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).