English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2010-07-25 (10:53)
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 :


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 :-) ?