From: "Daniel Bünzli" <daniel.buenzli@erratique.ch>
To: Martin Jambon <martin.jambon@ens-lyon.org>
Cc: caml-list List <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] Annotated trees
Date: Mon, 7 Jun 2010 11:22:48 +0200 [thread overview]
Message-ID: <AANLkTik0iDx-OGUSKw3ZCU-hV8OvWKH_HEndA85nube3@mail.gmail.com> (raw)
In-Reply-To: <4C0C7F08.3010403@ens-lyon.org>
> 1. Pattern-matching is more readable because the most important piece of
> information comes first:
>
> `Leaf (_, s) -> ...
> | `Node (_, l) -> ...
>
> instead of:
>
> (_, `Leaf s) -> ...
> | (_, `Node l) -> ...
I'm not sure I agree on this one since in the second case the
parentheses are not needed. And if you put the annotation in the
second component (as you suggest your second message) then we are back
to most important first and without parentheses :
let f = function
| `Leaf s, _ -> ...
| `Node l, _ -> ...
> 3. It is possible to not annotate certain kinds of nodes, or to have different
> types of annotations depending on the kind of node.
That's true and certainly a good argument for the second form if you
already know the type of your annotations and have such needs. However
if you want to keep that polymorphic (the annotation is a convenience
for the client) it results in a type variable per case which becomes
heavy.
> 4. The tuple version feels like there are 2 different definitions of a tree
> node, i.e. it is easy to get confused about whether an annotated node (the
> pair) or an non-annotated node (second member of the pair) is expected in one
> given place.
I can understand that. It's true that it may make you think that you
are able to get a non-annotated value by just dropping the first
component. On the other hand the rule is quite simple, you always work
with pairs, period.
> 5. I got this habit and therefore I won't change my mind and reject all
> rational arguments against it ;-)
Yes, that's mainly a discussion about taste.
Thanks for your comments,
Daniel
next prev parent reply other threads:[~2010-06-07 9:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-06 15:26 Daniel Bünzli
2010-06-07 5:09 ` [Caml-list] " Martin Jambon
2010-06-07 5:15 ` Martin Jambon
2010-06-07 9:22 ` Daniel Bünzli [this message]
2010-06-07 12:01 ` blue storm
2010-06-07 6:45 ` Jacques Garrigue
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=AANLkTik0iDx-OGUSKw3ZCU-hV8OvWKH_HEndA85nube3@mail.gmail.com \
--to=daniel.buenzli@erratique.ch \
--cc=caml-list@yquem.inria.fr \
--cc=martin.jambon@ens-lyon.org \
/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