From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p789IAVJ003003 for ; Mon, 8 Aug 2011 11:18:10 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkEGADOpP05beZio/2dsb2JhbABChEeTaY8Id4FAAQEFI2YLGgImAgJXiAisEpBfgSuEC4EQBJs4iDQ X-IronPort-AV: E=Sophos;i="4.67,336,1309730400"; d="scan'208";a="115254129" Received: from quare.fr ([91.121.152.168]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/AES256-SHA; 08 Aug 2011 11:18:05 +0200 Received: from bea-et-mathias.net ([178.33.165.110] helo=[192.168.1.78]) by quare.fr with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1QqLyG-0003KF-IO for caml-list@inria.fr; Mon, 08 Aug 2011 11:18:04 +0200 From: Mathias Kende To: caml-list@inria.fr In-Reply-To: <20110808080356.GD29083@localhost> References: <20110808131504.d9137220d4b4401cc3450e5a@mega-nerd.com> <20110808035322.GI29083@localhost> <20110808174619.00b76d12a02f2c58c10c0108@mega-nerd.com> <20110808080356.GD29083@localhost> Content-Type: text/plain; charset="UTF-8" Date: Mon, 08 Aug 2011 11:17:58 +0200 Message-ID: <1312795078.2593.4.camel@tele> Mime-Version: 1.0 X-Mailer: Evolution 2.32.3 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p789IAVJ003003 Subject: Re: [Caml-list] Val_int vs caml_copy_nativeint 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