From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 450FABB81 for ; Mon, 13 Feb 2006 10:45:25 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k1D9jOp6031812 for ; Mon, 13 Feb 2006 10:45:25 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA09980 for ; Mon, 13 Feb 2006 10:45:24 +0100 (MET) Received: from [128.93.8.130] (macadam.inria.fr [128.93.8.130]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k1D9jO08003080 for ; Mon, 13 Feb 2006 10:45:24 +0100 Mime-Version: 1.0 (Apple Message framework v746.2) In-Reply-To: <17391.40256.369673.840468@karryall.dnsalias.org> References: <20060119.093955.97297811.garrigue@math.nagoya-u.ac.jp> <1137640656.8943.183.camel@rosella> <02FDC6F0-122C-42BA-A2F4-15E2B08248C8@inria.fr> <17359.42955.268490.985894@karryall.dnsalias.org> <0E70B6E0-7C47-40FD-B5C7-51F497847047@inria.fr> <17391.40256.369673.840468@karryall.dnsalias.org> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <366DB9FB-3988-4D96-85BB-019BCF9307A6@inria.fr> Content-Transfer-Encoding: 7bit From: Damien Doligez Subject: Re: [Caml-list] C interface style question Date: Mon, 13 Feb 2006 10:45:50 +0100 To: caml users X-Mailer: Apple Mail (2.746.2) X-Miltered: at nez-perce with ID 43F05535.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 43F05534.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; damien:01 damien:01 caml-list:01 andrieu:01 pointer:01 mlvalues:01 val:01 val:01 admittedly:01 pointer:01 byte:01 wrote:01 doligez:01 doligez:01 abstract:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Feb 12, 2006, at 21:40, Olivier Andrieu wrote: >> This is correct, except for the way you get the pointer. You should >> do it >> properly with &(Double_field(ml_array,0)). There is no guarantee >> that >> the value ml_array points to the first element of the array. > in mlvalues.h, I have (with ARCH_ALIGN_DOUBLE undefined) : > > #define Double_val(v) (* (double *)(v)) > #define Double_field(v,i) Double_val((value)((double *)(v) + (i))) > > so &(Double_field(ml_array, 0)) looks pretty equivalent to a simple > cast to double*, no ? You should treat those definitions as abstract. It is purely for efficiency reasons that they are defined as macros. If we decide to change the representation of Caml values (admittedly a pretty remote possibility at this point), the pointer might not point to the first field of the array anymore. For example. it could point to the header, or to the second byte of the contents. -- Damien