From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id DD2B1BB84 for ; Sun, 23 Nov 2008 22:49:46 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtwAAF9eKUnU436xjmdsb2JhbACTXAEBAQEJCwgJDwW5SYJ8 X-IronPort-AV: E=Sophos;i="4.33,654,1220220000"; d="scan'208";a="31743791" Received: from moutng.kundenserver.de ([212.227.126.177]) by mail4-smtp-sop.national.inria.fr with ESMTP; 23 Nov 2008 22:49:46 +0100 Received: from [129.199.159.5] (rezo-159-5.ens.fr [129.199.159.5]) by mrelayeu.kundenserver.de (node=mrelayeu5) with ESMTP (Nemesis) id 0ML25U-1L4Mpt2QzH-00038a; Sun, 23 Nov 2008 22:49:46 +0100 Subject: RE: [Caml-list] Accessing constructors (tags) from C From: Mathias Kende Reply-To: mathias@kende.fr To: caml-list@yquem.inria.fr In-Reply-To: <005c01c94d9b$2fbec1b0$8f3c4510$@com> References: <49299F76.6090006@rice.edu> <005c01c94d9b$2fbec1b0$8f3c4510$@com> Content-Type: text/plain; charset="UTF-8" Date: Sun, 23 Nov 2008 22:49:20 +0100 Message-Id: <1227476960.6807.3.camel@MATHIAS-ENS> Mime-Version: 1.0 X-Mailer: Evolution 2.24.1 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V01U2FsdGVkX19uBBM3ScQxtcDReb+5lyfDjqG2Mf+EbnN9EYo f9awXc4XTs7cPYO66cmeSLAxLijKqOJtqVN/Fbr6Nn0r2zTWgm sTVAxOz4OyHhDJ73cdoKEJ4+kG2DLD0 X-Spam: no; 0.00; constructors:01 val:01 alloc:01 val:01 alloc:01 numbering:01 constructors:01 mathias:98 mathias:98 integer:01 caml-list:01 int:01 int:01 caml:02 caml:02 Le dimanche 23 novembre 2008 =C3=A0 18:42 +0000, David Allsopp a =C3=A9crit= : > See Section 18.3.4 of the manual. In your example below, Null is an > integer > 0 and Int is a 1-word block with tag 1. In C, Null is Val_int(0) and t > =3D > Int(x) is caml_alloc(1, 1); Store_field(t, 0, Val_int(x)). (Int x) is t =3D caml_alloc(1,0); Store_field(t,0,Val_int(x)). Because the numbering of the fields starts from zero separately for the constant and non-constant constructors (definitely, this is error prone). Mathias