[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2006-02-13 (09:45) |
From: | Damien Doligez <damien.doligez@i...> |
Subject: | Re: [Caml-list] C interface style question |
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