From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 5B049BC57 for ; Mon, 7 Jun 2010 11:22:49 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvYBAGJWDEzRVdvckWdsb2JhbACDHZsdCBUBAQEBCQsKBxEDH61cgjqEaIh9AQEDBYEhgwNuBI4N X-IronPort-AV: E=Sophos;i="4.53,377,1272837600"; d="scan'208";a="60776996" Received: from mail-ew0-f220.google.com ([209.85.219.220]) by mail1-smtp-roc.national.inria.fr with ESMTP; 07 Jun 2010 11:22:49 +0200 Received: by ewy20 with SMTP id 20so582372ewy.3 for ; Mon, 07 Jun 2010 02:22:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=l8nm8El3nNuJAWgRaHkQWjAInt5qinWuJbFzWBTL9xA=; b=Ir1RIEBARVlDafHrnH9akUmXGsbiFD+Tv+wwi+rnZAqvGkdDH/1BUDFYBWQPO0/W9a GskUu0DZzc9u4NknSgZmMRMT8+LBTyM3UITKODU6qsqUFDkbnjiYr7pzIfodrU2vlRGV L3SmJrbmCG4s5NCWUztj0h4O/K6B005s0XoLI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=gbbMmQLJQ77kktX2YPokC7mFFvD4bVrQB/Nv2NrYUrY1Pgt11pvG3E/fQKeSYDfDRf UXoEM030gr6h2xUv2gMt3UPZA9bp9Uz4yLQmDQFBTTUtXJxskxVgjRphOrsyLy5U8qS6 3smBTJMLeRrSvGhzefi/8COwcy6V5fGdLNH5w= MIME-Version: 1.0 Received: by 10.213.14.71 with SMTP id f7mr10922913eba.98.1275902568789; Mon, 07 Jun 2010 02:22:48 -0700 (PDT) Sender: daniel.c.buenzli@gmail.com Received: by 10.213.20.19 with HTTP; Mon, 7 Jun 2010 02:22:48 -0700 (PDT) In-Reply-To: <4C0C7F08.3010403@ens-lyon.org> References: <4C0C7F08.3010403@ens-lyon.org> Date: Mon, 7 Jun 2010 11:22:48 +0200 X-Google-Sender-Auth: gNDs-4UyQLkYbArxHoFtzPXYtpI Message-ID: Subject: Re: [Caml-list] Annotated trees From: =?UTF-8?Q?Daniel_B=C3=BCnzli?= To: Martin Jambon Cc: caml-list List Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; buenzli:01 node:01 node:01 nodes:01 annotations:01 annotations:01 polymorphic:01 readable:01 caml-list:01 pairs:01 parentheses:01 parentheses:01 pair:01 pair:01 tuple:02 > 1. Pattern-matching is more readable because the most important piece of > information comes first: > > =C2=A0 `Leaf (_, s) -> ... > =C2=A0| `Node (_, l) -> ... > > instead of: > > =C2=A0 (_, `Leaf s) -> ... > =C2=A0| (_, `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 =3D function | `Leaf s, _ -> ... | `Node l, _ -> ... > 3. It is possible to not annotate certain kinds of nodes, or to have diff= erent > 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 tr= ee > node, i.e. it is easy to get confused about whether an annotated node (th= e > 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