Version française
Home     About     Download     Resources     Contact us    
Browse thread
Encoding of (constructor * with * tuple)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: rixed@h...
Subject: Encoding of (constructor * with * tuple)
Hello list.

I'm using ocaml version 3.12.0+beta1, and reading the manual here :

http://caml.inria.fr/pub/docs/manual-ocaml/manual032.html#toc130

I have this datatype :

type color_specs = Array of vertex_array | Uniq of color

where :

type color = int * int * int * int
type vertex_array = (nativeint, Bigarray.nativeint_elt, Bigarray.c_layout) Bigarray.Array2.t

Values of type color_specs are passed to a C function.

>From the manual, I though that the value would be encoded in a block with a tag
of 0 (for Array) or 1 (Uniq). If Array, wosize would be 1 and the first and
only field would be a pointer to the bigarray, and if Uniq then the wosize
would be 4 and the four fields would be the unboxed integers.

But apparently I'm wrong since for the Uniq case the wosize is still 1 and the
first field points to the tupple of 4 ints which is allocated separately,
despite that the manual clearly says : "Non-constant constructors declared with
a n-tuple as argument are represented by a block of size n, tagged with the
constructor number; the n fields contain the components of its tuple argument." 

So who's wrong ? ocamlc ? the manual ? or just me :-) ?