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 64D69BB81 for ; Thu, 23 Feb 2006 19:56:27 +0100 (CET) Received: from mail.davidb.org (mail.davidb.org [66.93.32.219]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k1NIuP3s017549 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 23 Feb 2006 19:56:26 +0100 Received: from davidb by mail.davidb.org with local (Exim 4.54 #1 (Debian)) id 1FCLdY-00072g-GO; Thu, 23 Feb 2006 10:56:24 -0800 Date: Thu, 23 Feb 2006 10:56:24 -0800 From: David Brown To: =?iso-8859-1?Q?Fr=E9d=E9ric?= Gava Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] (int * int) <> int*int ? Message-ID: <20060223185624.GA26907@old.davidb.org> References: <006101c6389e$9bbbc440$1f570b50@mshome.net> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <006101c6389e$9bbbc440$1f570b50@mshome.net> User-Agent: Mutt/1.5.11 X-Miltered: at concorde with ID 43FE0559.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 caml-list:01 gava:01 compiler:01 constructors:01 wrote:01 pair:01 pair:01 tuples:01 immutable:01 int:01 int:01 semantic:02 tuple:02 tuple:02 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=SPF_SOFTFAIL autolearn=disabled version=3.0.3 On Thu, Feb 23, 2006 at 06:28:48PM +0100, Frédéric Gava wrote: > I understand that it'is force you to have a pair for A and not just a value > of type pair but why this restriction ? It is not easy to explain why > int*int <> (int*int). As others have explained the represenatation is different. The constructed types themselves can contain multiple values (represented the same way as a tuple). Consider type a = A of int * int | B of (int * int) The result of A (3, 4) will be a two element tuple type tagged appropriately for 'A' (in this case 0). The result of B (3, 4) will be a one element tuple type tagged for B, with the single element referring to the two element tuple containing (3, 4). Because tuples are generally immutable, there is little semantic difference, but the compiler does have to keep track of which is which. In most cases I would guess that 'A' would be more efficient (unless there are lots of larger constructors sharing the same tuple). Dave