caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: David Teller <David.Teller@ens-lyon.org>
To: caml-list@yquem.inria.fr
Subject: Feature request : Tuples vs. records
Date: Thu, 22 Feb 2007 11:25:16 +0100	[thread overview]
Message-ID: <45DD6F8C.7080508@ens-lyon.org> (raw)

A long time ago, I used to believe that there was a large difference 
between tuples and records: tuples constructors/patterns use the order 
of their arguments to determine where they fit in the data structure, 
while records use the name of arguments. And then, labels arrived and 
somehow made possible to use either style when it comes to defining and 
applying functions.

Now, of course, I have the task of teaching OCaml to students. When it 
comes to explaining the difference between tuples and records, I'm 
suddenly unsure. Why is there a difference at all ? Aren't records the 
same thing as tuples with labels ? Couldn't/shouldn't the next version 
of OCaml uniformize both syntaxes and get us rid of {} once and for all ?

I envision something like
# (1,2);;
- : int * int = (1, 2)

# let pair_2 = (~x:1, ~y:2);;
pair_2 : x:int * y:int = (1, 2)

# let pair_3 = (~y:2, ~x:1);;
pair_3 : y:int * x:int = (2, 1)    (*or perhaps normalisation, say based 
on the lexicographical order of labels*)

# pair_2 = pair_3;; (*structural equality*)
true

# match pair_2 with (~y:y, ~x:x) -> (x,y);;
- : int * int = (1, 2)


Is anything such considered ?

Thanks,
 David


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

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-22 10:25 David Teller [this message]
2007-02-22 10:42 ` [Caml-list] " Andrej Bauer
2007-02-22 12:41   ` 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

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=45DD6F8C.7080508@ens-lyon.org \
    --to=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).