caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Sylvain Le Gall <sylvain@le-gall.net>
To: caml-list@inria.fr
Subject: Re: OCaml/C variant representation
Date: Sun, 28 Feb 2010 16:22:36 +0000 (UTC)	[thread overview]
Message-ID: <slrnhol62c.ckm.sylvain@gallu.homelinux.org> (raw)
In-Reply-To: <9dfe358d1002280716t4b756138m476455f1e86e44be@mail.gmail.com>

On 28-02-2010, Jianzhou Zhao <jianzhou@seas.upenn.edu> wrote:
> On Wed, Feb 24, 2010 at 11:42 AM, Sylvain Le Gall <sylvain@le-gall.net> wrote:
>> On 24-02-2010, Jean Yang <jeanyang@csail.mit.edu> wrote:
>> Please have a look at:
>> http://caml.inria.fr/mantis/view.php?id=4803
>>
>> This section is misleading. You should use hash_variant for `VConstr.
>>
>> In your case VConstr of int will be Block with size = 1 and tag = 0;
>> first non-constant constructor and first field contains Value_int(...)
>
> If I am creating an OCaml variant (string option) from C, say using 'alloc',
> does it matter which tag I am using for 'some'? Can it be only tag 0?
> I was looking at LLVM OCamling bindings, sometimes the 'some' is
> also of 'tag 1', which confused me.

I think it is an error, but since there is only one possibility in the
case of Some, maybe it is not important (i.e. you can distingish between
the two variant None | Some just looking at the fact there are block or
not).

> If my variant is A | B | C of int | D of int, does C have to start from tag 0?
> and D must be 1? Similarly, does A have to be assigned into Val_int(0),
> and B is from 1?

Yes. At least this is what I understand from section "18.3.4 Concrete
types" of the OCaml manual. As a matter of fact, I never had problems
following this convention before. 

Regards,
Sylvain Le Gall


  reply	other threads:[~2010-02-28 16:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-24 15:26 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 [this message]
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=slrnhol62c.ckm.sylvain@gallu.homelinux.org \
    --to=sylvain@le-gall.net \
    --cc=caml-list@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).