From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id E00FABB81 for ; Thu, 23 Feb 2006 22:18:34 +0100 (CET) Received: from ptb-relay01.plus.net (ptb-relay01.plus.net [212.159.14.212]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k1NLIYUl031559 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Thu, 23 Feb 2006 22:18:34 +0100 Received: from [80.229.56.224] (helo=chetara) by ptb-relay01.plus.net with esmtp (Exim) id 1FCNr7-0003UN-TL for caml-list@yquem.inria.fr; Thu, 23 Feb 2006 21:18:34 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] (int * int) <> int*int ? Date: Thu, 23 Feb 2006 20:58:58 +0000 User-Agent: KMail/1.9.1 References: <006101c6389e$9bbbc440$1f570b50@mshome.net> In-Reply-To: <006101c6389e$9bbbc440$1f570b50@mshome.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200602232058.59170.jon@ffconsultancy.com> X-Miltered: at concorde with ID 43FE26AA.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 gava:01 semantically:01 afaik:01 runtime:01 char:01 run-time:01 run-time:01 val:01 val:01 globl:01 globl:01 constructors:01 variants:01 ocaml:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Thursday 23 February 2006 17:28, Fr=E9d=E9ric Gava wrote: > is anybody can semantically explain why this 2 types are differents ? > > # type t=3DA of int*int and t'=3D B of (int*int);; > type t =3D A of int * int > and t' =3D B of (int * int) Only historical reasons, AFAIK. I do not believe this is necessary or that= =20 there is a logical reason for doing so. > Morever I think that int*int=3D(int*int) in ML Yes. I think it is logical to expect that. > > And since the runtime representations are different, the types have to = be > > different. > > Wrong, you can the same representation but different types (e.g. int, char > or many other examples) I also believe that statement was wrong but I don't think you have provided= =20 counter-examples because the run-time representations are the same for the= =20 different types that you cite (rather than the converse). Perhaps this is a better counterexample: the following functions "f" and "g= "=20 use different run-time representations but still have the same type: # let f (a, b) =3D a+b let g (a, b as x) =3D a+b;; val f : int * int -> int =3D val g : int * int -> int =3D camlT2__f_58: =2EL100: lea -1(%eax, %ebx), %eax ret .text .align 16 .globl camlT2__g_61 .type camlT2__g_61,@function camlT2__g_61: =2EL101: movl 4(%eax), %ebx movl (%eax), %eax lea -1(%eax, %ebx), %eax ret .text .align 16 .globl camlT2__entry .type camlT2__entry,@function I suspect a similar transformation could be done for variant type=20 constructors. Also, note that this behaviour does not appear with polymorphic variants,=20 where int * int <=3D> (int * int): # type t =3D A of int * int | B of (int * int);; type t =3D A of int * int | B of (int * int) # type t =3D [ `A of int * int | `B of (int * int) ];; type t =3D [ `A of int * int | `B of int * int ] I assume the arguments of a polymorphic variant are always boxed... =2D-=20 Dr Jon D Harrop, Flying Frog Consultancy Ltd. Objective CAML for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists