Version française
Home     About     Download     Resources     Contact us    
Browse thread
(int * int) <> int*int ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Frédéric_Gava <gava@u...>
Subject: Re: [Caml-list] (int * int) <> int*int ?
> Because tuples are generally immutable, there is little semantic
> difference, but the compiler does have to keep track of which is which.

Thanks, but which differnce ?

>In most cases I would guess that 'A' would be more efficient (unless there
are
> lots of larger constructors sharing the same tuple).
Peraps in patter mathching:

# type t = A of int*int | B of (int*int);;
type t = A of int * int | B of (int * int)

# fun x -> match x with A (a,b) -> (a,b) | B a -> a;;
- : t -> int * int = <fun>

where the case of B will be more efficient since the are not need to rebuild
a pair

Best,
FG