Version française
Home     About     Download     Resources     Contact us    
Browse thread
Unboxed float tuples
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Martin Jambon <martin.jambon@e...>
Subject: Re: [Caml-list] Unboxed float tuples
Daniel Bünzli wrote:
> Tuples and records are represented the same way. However when it comes
> to records with only floats fields we get a special unboxed
> representation.
> 
> Why don't we get that for tuples of floats only ?

Because polymorphic functions like fst would break (or would require extra
runtime checking).

Note that ('a * 'b) is pretty much the same as:
type ('a, 'b) tuple = { a : 'a; b : 'b }


# Obj.tag (Obj.repr { a = 1.0; b = 1.0 });;
- : int = 0
# Obj.tag (Obj.repr (1.0, 1.0));;
- : int = 0


whereas:

# Obj.tag (Obj.repr { Complex.re = 1.0; im = 1.0 });;
- : int = 254



Martin

-- 
http://mjambon.com/