caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Andrej Bauer <Andrej.Bauer@fmf.uni-lj.si>
To: David Teller <David.Teller@ens-lyon.org>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Feature request : Tuples vs. records
Date: Thu, 22 Feb 2007 11:42:48 +0100	[thread overview]
Message-ID: <45DD73A8.3040703@fmf.uni-lj.si> (raw)
In-Reply-To: <45DD6F8C.7080508@ens-lyon.org>

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


  reply	other threads:[~2007-02-22 10:38 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-22 10:25 David Teller
2007-02-22 10:42 ` Andrej Bauer [this message]
2007-02-22 12:41   ` [Caml-list] " skaller
2007-02-22 13:55     ` David Teller
2007-02-22 15:44       ` Jon Harrop
2007-02-22 19:45       ` Tom
2007-02-22 23:26         ` skaller
2007-02-22 15:28     ` Andreas Rossberg
2007-02-22 15:57       ` Till Varoquaux
     [not found]         ` <45DDC424.2020804@ens-lyon.org>
2007-02-22 16:57           ` Till Varoquaux
2007-02-22 17:19             ` brogoff
2007-02-22 15:34 Frederic GAVA
2007-02-22 16:16 ` David Teller
2007-02-23  1:39   ` Jacques Garrigue
2007-02-23 13:34     ` Richard Jones
2007-02-23 13:43       ` Till Varoquaux
2007-02-23 14:14         ` Nicolas Pouillard
2007-02-23  1:45   ` Jon Harrop
2007-02-23 16:32     ` Lukasz Stafiniak
2007-02-24 13:43       ` Lukasz Stafiniak
2007-02-24 15:50         ` Brian Hurt
2007-02-24 18:14           ` skaller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45DD73A8.3040703@fmf.uni-lj.si \
    --to=andrej.bauer@fmf.uni-lj.si \
    --cc=Andrej.Bauer@andrej.com \
    --cc=David.Teller@ens-lyon.org \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).