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,

And it does not justify why
# type t=A of int*int
type t = A of int * int
# let a=2,3;;
val a : int * int = (2, 3)
# (A a);;
The constructor A expects 2 argument(s), but is here applied to 1
argument(s)

You have build "a" of type int * int which is the parameter of A and it is
not good ;-( (I understand the idea of the difference that  the constructor
take n arguments or 1 argument of n values (i.e curryied or not) but despite
that you could not write (A 1 2), I do not understand why there is a
difference). For performance issues, is there a way to not have the rebuild
of the pair in
# type t = A of int*int | B of (int*int);;
# fun x -> match x with A (a,b) -> (a,b) | B a -> a;;

?

FG