caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Mathias Kende <mathias@kende.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Val_int vs caml_copy_nativeint
Date: Mon, 08 Aug 2011 11:17:58 +0200	[thread overview]
Message-ID: <1312795078.2593.4.camel@tele> (raw)
In-Reply-To: <20110808080356.GD29083@localhost>

Le lundi 08 août 2011 à 10:03 +0200, Guillaume Yziquel a écrit :
> With Val_int, you have an integral value in the tuple's field.
> 
> With caml_copy_nativeint, you have a pointer in the tuple's field.

More explicitly, Val_int creates you a value of type int in the OCaml
world, while caml_copy_nativeint creates you a value of type natint in
the OCaml world. That's why you have two different "functions" in the
first place.

natints (and strings) are allocated blocks in OCaml so you need to copy
the data from the C world to some place in OCaml heap. Hence the
caml_copy_... function. You don not need such function for ints which
are directly stored in the value variable.

Mathias



  reply	other threads:[~2011-08-08  9:18 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-08  3:15 Erik de Castro Lopo
2011-08-08  3:48 ` Romain Beauxis
2011-08-08  3:59   ` Guillaume Yziquel
2011-08-08  7:49     ` Erik de Castro Lopo
2011-08-08  3:53 ` Guillaume Yziquel
2011-08-08  7:46   ` Erik de Castro Lopo
2011-08-08  8:03     ` Guillaume Yziquel
2011-08-08  9:17       ` Mathias Kende [this message]
2011-08-08 17:24       ` Xavier Leroy
2011-08-09  1:33         ` Erik de Castro Lopo
2011-08-09  1:40           ` Romain Beauxis
2011-08-09  8:44           ` David Allsopp
2011-08-09 10:07             ` malc
2011-08-09 10:43               ` David Allsopp
2011-08-09 22:53           ` Erik de Castro Lopo
2011-08-10  6:43             ` Gabriel Scherer
2011-08-08  5:20 ` malc
2011-08-08  6:01   ` Guillaume Yziquel
2011-08-08  6:22     ` malc

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=1312795078.2593.4.camel@tele \
    --to=mathias@kende.fr \
    --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).