From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id B963CBB91 for ; Wed, 26 Jan 2005 17:04:18 +0100 (CET) Received: from ptb-relay01.plus.net (ptb-relay01.plus.net [212.159.14.212]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j0QG4Ij7025119 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 26 Jan 2005 17:04:18 +0100 Received: from [80.229.56.224] (helo=chetara) by ptb-relay01.plus.net with esmtp (Exim) id 1CtpeQ-000EIR-Qs for caml-list@yquem.inria.fr; Wed, 26 Jan 2005 16:04:14 +0000 From: Jon Harrop Organization: University of Cambridge To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] 'a Set? Date: Wed, 26 Jan 2005 16:06:15 +0000 User-Agent: KMail/1.7.1 References: <727068A7-6F2C-11D9-8411-0003939A19AA@fas.harvard.edu> <200501260913.09018.jon@jdh30.plus.com> <003d01c503bc$dea027a0$0100a8c0@mshome.net> In-Reply-To: <003d01c503bc$dea027a0$0100a8c0@mshome.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200501261606.15465.jon@jdh30.plus.com> X-Miltered: at nez-perce with ID 41F7BF82.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 gava:01 wrote:01 coherence:01 stdlib:01 semantics:01 arrays:01 mappings:01 variants:01 variants:01 cheers:01 ...:98 arbitrary:01 interfaces:01 interfaces:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: On Wednesday 26 January 2005 15:36, Fr=E9d=E9ric Gava wrote: > ... > Ok, I am agree. It is just a remark about coherence of names of functions > and > interfaces of the modules in the stdlib. There is many ModuleName.S > interfaces. Have the same names for functions that have the same semantics > seems (to me) a good things. (for example, have a function cardinal in t= he > module Map, even if we could implemented this with a fold; the cardinal > function of the Sets are could also be implemented with a fold) There are several problems with this. Firstly, the name "cardinal". A set h= as=20 cardinality. Lists and arrays have length. In C++ the equivalent function i= s=20 "size". Should a map use one of those names or something else (is a map a=20 _set_ of mappings? =3D> "cardinal"). Secondly, there are numerous variants on a theme here. You suggest=20 implementing Map.cardinal with a fold =3D> O(n). This may be the best that = can=20 be done at the moment (assuming the internal representation stores maximum= =20 depth but not number of elements) but by storing the number of elements in= =20 all branches you could have O(1) "cardinal". Of course, there are other=20 variants too (e.g. min =3D max =3D d depth =3D> 2^d - 1 elements). Ultimately, the core library is maintained by INRIA who can ill-afford to=20 expend man-hours on adding arbitrary functionality to the core library. I=20 would love to see such inclusions (and many others). Perhaps I should make a webpage listing useful things for people to dabble= =20 on. :-) Cheers, Jon.