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=1.1 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 3DCE6BC69 for ; Thu, 22 Feb 2007 16:57:29 +0100 (CET) Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.236]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l1MFvRHf020791 for ; Thu, 22 Feb 2007 16:57:28 +0100 Received: by nz-out-0506.google.com with SMTP id i11so210058nzh for ; Thu, 22 Feb 2007 07:57:27 -0800 (PST) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Hk5yVxdbeRaTODJh5Kb215CwB5N4Noyd9/xCrhfHHQUrPOKcbMTdoCe6zrrP6w71AHpZFwM/zGT/z2BKUGj8S4RBxp+AH77wpJufbBGGim9yZ6JaSYxGejVlFXFMU4QTr+dVMPxzmEckh9q0lLLjYpIFPSgSPy7THIdFv7W8yT0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=tTTuEImfZIY8lqtuO+a9d833TE6ovPLaHRgfhvS4DkJNLegz6bO2RW+LbfWoZc0bACchdrjlKxnZrIPNF5eGy4EoDGG937kISAmCSl2ar19tDx1fX2HO/GqHnyUVyVvV8W3ZNWrtS2M23DRKx6LrMmv74XgTSpU5WlTpOZuSTSo= Received: by 10.65.152.17 with SMTP id e17mr1332909qbo.1172159846879; Thu, 22 Feb 2007 07:57:26 -0800 (PST) Received: by 10.65.98.10 with HTTP; Thu, 22 Feb 2007 07:57:26 -0800 (PST) Message-ID: <9d3ec8300702220757s5c75c7feqee62f051841d1c38@mail.gmail.com> Date: Thu, 22 Feb 2007 16:57:26 +0100 From: "Till Varoquaux" To: "Andreas Rossberg" Subject: Re: [Caml-list] Feature request : Tuples vs. records Cc: caml-list@yquem.inria.fr In-Reply-To: <45DDB697.6080004@ps.uni-sb.de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <45DD6F8C.7080508@ens-lyon.org> <45DD73A8.3040703@fmf.uni-lj.si> <1172148077.5345.18.camel@rosella.wigram> <45DDB697.6080004@ps.uni-sb.de> X-j-chkmail-Score: MSGID : 45DDBD67.002 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 45DDBD67.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; mutable:01 verbose:01 rossberg:01 rossberg:01 ocaml:01 sml:01 ocaml:01 structurally:01 sml:01 syntax:01 beginner's:01 bug:01 polymorphic:01 beginners:01 wrote:01 Another simple difference is that you have to declare the type of the records whereas types of tupples can be infered. Since the typechecer actually uses the type information given, you can use polymorphic fields to implement general reccursivity. I would also mention row polymorphisme and "mutable" as notable differences. You could also note that they are not always interchangeable: whilst you wouldn't want to define a new record type for every tupple you use (very verbose), direct access to a defined field and the "with" keyword (e.g let b={a with x=1}) make records nice to handle large structures. Till On 2/22/07, Andreas Rossberg wrote: > skaller wrote: > > > >> By the way, I always wondered why ocaml doesn't have generic projection > >> operations from cartesian products (I belive they are writen #1, #2, #3 > >> ... in SML). > > > > There's another difference in Ocaml: records > > are nominally typed, tuples are structurally typed. > > In fact, these are closely related. In SML, tuples *are* records: the > syntax (x,y) is merely syntactic sugar for {1=x, 2=y}, where 1 and 2 are > numeric labels. Record projection #lab thus naturally applies to tuples. > However, that definition of tuples requires structural record typing. > > -- > Andreas Rossberg, rossberg@ps.uni-sb.de > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >