From: Brian Hurt <bhurt@spnz.org>
To: Lukasz Stafiniak <lukstafi@gmail.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Feature request : Tuples vs. records
Date: Sat, 24 Feb 2007 10:50:45 -0500 (EST) [thread overview]
Message-ID: <Pine.LNX.4.64.0702241043560.19734@localhost> (raw)
In-Reply-To: <4a708d20702240543w4c9d0a91tb12c13b10254a68b@mail.gmail.com>
On Sat, 24 Feb 2007, Lukasz Stafiniak wrote:
> I have this idea... We could have row polymorphism in tuples, without
> any impact on performance! Instead of insisting that ('a * 'b) means
> exactly two elements, we could have (> 'a * 'b) at least two elements.
> Any projections or pattern matching fetches the tuple fields without
> problems: it doesn't need to care that there are more than it needs.
>
> Say you realize that you need to return another value from a function
> (which already returns a tuple): you would only modify the function
> and not its uses.
Not being able to do this is one of the reasons I *like* Ocaml.
Consider the case where the calling location is:
let a, b = foo ... in
...
Now you change foo to return 3 tuples instead of just 2. What happens?
If you say "The third element quietly gets dropped", I'll respond with "if
I wanted that behavior, I'd be coding in Perl."
If you've changed what you're returning, you've change the semantics of
the function- what it means is now different. And it's a good idea to go
look at every place where it's called, and consider what effect this
change in semantics will have on that code. Ocaml is very helpfull in
that it will tell you every place you need to look at to deal with this
change- filename and line number. Note that if you, the programmer,
decide that the right thing to do is to just drop the new third argument,
it's real easy ro change the calling code to just:
let a, b, _ = foo ... in
...
Brian
next prev parent reply other threads:[~2007-02-24 15:37 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=Pine.LNX.4.64.0702241043560.19734@localhost \
--to=bhurt@spnz.org \
--cc=caml-list@yquem.inria.fr \
--cc=lukstafi@gmail.com \
/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