From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id AA33BBCAC for ; Mon, 30 May 2005 02:28:52 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j4U0SqP4024955 for ; Mon, 30 May 2005 02:28:52 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id CAA05063 for ; Mon, 30 May 2005 02:28:51 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j4U0SnRm024950 for ; Mon, 30 May 2005 02:28:50 +0200 Received: from localhost (suiren [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.13.1/8.13.1) with ESMTP id j4U0Sf0X014114; Mon, 30 May 2005 09:28:42 +0900 (JST) Date: Sun, 29 May 2005 20:27:40 -0400 (EDT) Message-Id: <20050529.202740.07649159.garrigue@math.nagoya-u.ac.jp> To: yminsky@cs.cornell.edu Cc: caml-list@inria.fr Subject: Re: [Caml-list] Seemingly inconsistent labels for List module From: Jacques Garrigue In-Reply-To: <891bd33905052818563ef06063@mail.gmail.com> References: <891bd33905052818563ef06063@mail.gmail.com> X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 429A5E44.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 429A5E41.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 yaron:01 minsky:01 yminsky:01 memq:01 conversely:01 polymorphic:01 avoids:01 functions:01 functions:01 define:01 jacques:01 jacques:01 labels:02 labels:02 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: From: Yaron Minsky > I've noticed what appear to be inconsistent labelling on some list > functions, and I'm wondering if I'm properly understanding the reasons > behind the way the labels work. > > For example, in the various association list functions, in some cases > the association list is passed with a ~map label, and sometimes with > no label. Another odd case is the mem and memq functions, both of > which label the list being queried with the label ~set. In this case, > the labelling mostly seems kind of useless rather than inconsistent. There are reasons for both :-) The ~set label is there, so that you can easily define the membership function. let in_a = List.mem ~set:a Same thing for ~map in List.mem_assoc. However, there is no label in List.remove_assoc, because there it doesn't really make sense: it maps an association list to a new association list. There is no label either in List.assoc for a dirty reason: as the result is a polymorphic variable, if there were a label, one wouldn't be able to omit it in applications. List.assoc is used very often. > I'm asking all of this because I'm playing around with writing a > labelled version of the extlib interface, and I'm wondering whether > these are mistakes that should be fixed, or whether there are good > reasons for them and they should be preserved. So, there are good reasons, but you may make different choices. The labelling of the standard library is intentionally light; in other libraries you might want to put more. Or, conversely, if you choose to have only a labelled version (avoids maintaining two versions), you must be careful of using labels only where they will not get in the way. Jacques Garrigue