caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re: [Caml-list] Feature request : Tuples vs. records
@ 2007-02-22 15:34 Frederic GAVA
  2007-02-22 16:16 ` David Teller
  0 siblings, 1 reply; 21+ messages in thread
From: Frederic GAVA @ 2007-02-22 15:34 UTC (permalink / raw)
  To: David Teller, caml-list

Hi David,

Another difference is that (If I remember) record of float are unboxed and not tuple of float. But perhaps it could be done.

Also, I do understand the true difference between write
{x=1;y=2} (9 caracters) and (~x:1,~y:2) (11 caracters) except syntaxic one (I thinks that = is simpler that : which is more for type)

Frédéric Gava



> 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
> 
> _______________________________________________
> 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
> 
>


^ permalink raw reply	[flat|nested] 21+ messages in thread
* Feature request : Tuples vs. records
@ 2007-02-22 10:25 David Teller
  2007-02-22 10:42 ` [Caml-list] " Andrej Bauer
  0 siblings, 1 reply; 21+ messages in thread
From: David Teller @ 2007-02-22 10:25 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2007-02-24 18:14 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-22 15:34 [Caml-list] Feature request : Tuples vs. records 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
  -- strict thread matches above, loose matches on Subject: below --
2007-02-22 10:25 David Teller
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

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).