Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Records typing
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <garrigue@k...>
Subject: Re: [Caml-list] Records typing
From: malc <>

> > # module M = struct type t = float and r = {f:t} end;;
> > # module M' = struct type t = float type r = {f : t} end;;
> > 
> > In the first case, the record is represented as an array of a pointer
> > to a boxed float, while in the second case it is represented as an
> > array of an unboxed float. Since the data representation is different,
> > these two signatures are not equivalent. I was afraid there would be
> > no direct way to express the first case, but actually you can.
> What exactly triggered the switch from boxed to unboxed repersentation?
> I mean, this is completely unobvious and can have severe performance
> degradation, so description of cases when this might happen could be
> useful.

This the use of "and". In mutually recursive type definitions, other
types are not "known" during the definition, and as a result their
representation cannot be used for optimization. I think this is true
for all ocaml releases, but it is specified nowhere, and could be
Since you're not going to write the first defintion anyway, this
shouldn't be a real problem.
The real problem is that when you use a signature like
  sig type t type r = {f:t} end
in a functor, then this signature cannot be instanciated by the
unboxed version of r when t = float. And there is no way to solve it
short of inlining functors.


Jacques Garrigue
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: