From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA05038; Mon, 20 Sep 2004 22:22:18 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 WAA04407 for ; Mon, 20 Sep 2004 22:22:17 +0200 (MET DST) 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 i8KKMHbK032054 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 20 Sep 2004 22:22:17 +0200 Received: from [80.229.56.224] (helo=chetara) by ptb-relay01.plus.net with esmtp (Exim) id 1C9Ufr-000C0h-Mx for caml-list@inria.fr; Mon, 20 Sep 2004 20:22:11 +0000 From: Jon Harrop To: caml-list Subject: Re: [Caml-list] Core library (was: type var in functor instance?) Date: Mon, 20 Sep 2004 21:17:42 +0100 User-Agent: KMail/1.6.2 References: <1095516867.2580.211.camel@pelican.wigram> <16718.50690.954027.644373@gargle.gargle.HOWL> <1095694982.2580.595.camel@pelican.wigram> In-Reply-To: <1095694982.2580.595.camel@pelican.wigram> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200409202117.42329.jon@jdh30.plus.com> X-Miltered: at nez-perce with ID 414F3BF9.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 functor:01 2004:99 pervasives:01 distro:01 hashtbl:01 hashtbl:01 hash:01 implemented:01 coders:01 functor:01 hash:01 incorrectly:01 semantically:01 productive:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Monday 20 September 2004 16:43, skaller wrote: > > - to make an unfunctorized version of Set that uses Pervasives.compare, > > thus polymorphic > > This is already in the standard distro for Hashtbl. > Why not for Set and Map as well? Why is this > unsatisfactory? You mean Hashtbl uses a polymorphic hash? I think it would be productive to factor the tree out of set and map. What if someone released backwards-compatible replacement modules for List, Array, Set, Map etc. which implemented this stuff? Then package maintainers could replace them if they liked the alternative implementations and coders could assume their existence. Maybe. > I actually use heaps of Hashtbl of polymorphic kind > and am ready to switch some over to an functor instance > with key type int -- most of my tables use int keys > and I hope to gain some performance and reasoning ability. IMHO, hash tables are a bit less safe than sets and maps because hash tables make it easier to apply a structure-based polymorphic function incorrectly, e.g. to many abstract types, when a semantically meaningful (e.g. comparison) function should be used. For example, I don't think a hash table of sets would be very useful... This strikes me as an important way to screw up ML programs and, consequently, it would be nice to address this. I've been trying to think of a solution but all I've come up with is: you could enforce the use of an appropriate comparison by making everything an object with its own compare method. But then you're going back to dynamic typing. Perhaps phantom types could do it... Cheers, Jon. ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners