From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 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 AF3DCBC69 for ; Sat, 24 Feb 2007 16:37:53 +0100 (CET) Received: from bsd4.nyct.net (mail-out4.nyct.net [216.139.141.4]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l1OFbq7c026711 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 24 Feb 2007 16:37:53 +0100 Received: from [216.139.138.12] ([216.139.138.12]) by bsd4.nyct.net (8.13.4/8.13.4) with ESMTP id l1OFbkvm044920; Sat, 24 Feb 2007 10:37:49 -0500 (EST) (envelope-from bhurt@spnz.org) Date: Sat, 24 Feb 2007 10:50:45 -0500 (EST) From: Brian Hurt X-X-Sender: bhurt@localhost To: Lukasz Stafiniak Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Feature request : Tuples vs. records In-Reply-To: <4a708d20702240543w4c9d0a91tb12c13b10254a68b@mail.gmail.com> Message-ID: References: <7639252.205431172158497978.JavaMail.www@wwinf2216> <45DDC1CB.2090401@ens-lyon.org> <200702230145.55947.jon@ffconsultancy.com> <4a708d20702230832m4e143586i6036980ead10042a@mail.gmail.com> <4a708d20702240543w4c9d0a91tb12c13b10254a68b@mail.gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Miltered: at concorde with ID 45E05BD0.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; lukasz:01 polymorphism:01 ocaml:01 foo:01 foo:01 semantics:01 semantics:01 ocaml:01 2007,:98 wrote:01 caml-list:01 tuples:01 tuples:01 argument:02 tuple:02 On Sat, 24 Feb 2007, Lukasz Stafiniak wrote: > I have this idea... We could have row polymorphism in tuples, without > any impact on performance! Instead of insisting that ('a * 'b) means > exactly two elements, we could have (> 'a * 'b) at least two elements. > Any projections or pattern matching fetches the tuple fields without > problems: it doesn't need to care that there are more than it needs. > > Say you realize that you need to return another value from a function > (which already returns a tuple): you would only modify the function > and not its uses. Not being able to do this is one of the reasons I *like* Ocaml. Consider the case where the calling location is: let a, b = foo ... in ... Now you change foo to return 3 tuples instead of just 2. What happens? If you say "The third element quietly gets dropped", I'll respond with "if I wanted that behavior, I'd be coding in Perl." If you've changed what you're returning, you've change the semantics of the function- what it means is now different. And it's a good idea to go look at every place where it's called, and consider what effect this change in semantics will have on that code. Ocaml is very helpfull in that it will tell you every place you need to look at to deal with this change- filename and line number. Note that if you, the programmer, decide that the right thing to do is to just drop the new third argument, it's real easy ro change the calling code to just: let a, b, _ = foo ... in ... Brian