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 C446EBC69 for ; Thu, 22 Feb 2007 11:38:42 +0100 (CET) Received: from postar.fmf.uni-lj.si (vega.fmf.uni-lj.si [193.2.67.45]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l1MAcgjr029953 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 22 Feb 2007 11:38:42 +0100 Received: from localhost (unknown [192.168.5.1]) by postar.fmf.uni-lj.si (Postfix) with ESMTP id B7B561106D5; Thu, 22 Feb 2007 11:38:41 +0100 (CET) X-Virus-Scanned: amavisd-new at spam.fmf.uni-lj.si Received: from postar.fmf.uni-lj.si ([192.168.5.5]) by localhost (spam.fmf.uni-lj.si [192.168.5.1]) (amavisd-new, port 10024) with ESMTP id PC1DJPCgWxAz; Thu, 22 Feb 2007 11:53:11 +0100 (CET) Received: from [193.2.67.88] (unknown [193.2.67.88]) by postar.fmf.uni-lj.si (Postfix) with ESMTP id 689031113F7; Thu, 22 Feb 2007 11:38:41 +0100 (CET) Message-ID: <45DD73A8.3040703@fmf.uni-lj.si> Date: Thu, 22 Feb 2007 11:42:48 +0100 From: Andrej Bauer Reply-To: Andrej.Bauer@andrej.com User-Agent: Icedove 1.5.0.9 (X11/20061220) MIME-Version: 1.0 To: David Teller Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Feature request : Tuples vs. records References: <45DD6F8C.7080508@ens-lyon.org> In-Reply-To: <45DD6F8C.7080508@ens-lyon.org> Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 45DD72B2.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; andrej:01 andrej:01 constructors:01 constructors:01 programmer's:01 datatype:01 ocaml:01 sml:01 ..,:98 naming:01 caml-list:01 interfaces:01 tuples:01 tuples:01 define:01 Tuples and records are the same thing from the mathematical point of view, namely they are all just finite products. The only difference is that in once case the components are called 1, 2, 3, .., n and in the other the components have custom names. When I teach this stuff to students I first introduce tuples and later records. I tell them records are like tuples with named components, from which it follows that the order is not important. I also tell them (since they know Java), that records are a bit like simple-minded classes without inheritance, interfaces, methods and constructors (except they have constructors "built-in"). From programmer's point of view it is better to have both tuples and records because they serve different purposes: 1) Tuples are syntactially "light-weight" and allow one to easily handle several values at the same time (without having to define a datatype) 2) Records allow the programmer to remember which component is what by naming them. 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). Andrej