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 CAA09188; Wed, 15 Jan 2003 02:06:02 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id CAA09235 for ; Wed, 15 Jan 2003 02:06:01 +0100 (MET) Received: from wetware.wetware.com (wetware.wetware.com [199.108.16.1]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h0F160r28260 for ; Wed, 15 Jan 2003 02:06:00 +0100 (MET) Received: from wetware.com(ra07.wetware.com[199.108.16.87]) (1713 bytes) by wetware.wetware.com via sendmail with P:esmtp/R:bind_hosts/T:inet_zone_bind_smtp (sender: ) id for ; Tue, 14 Jan 2003 17:05:59 -0800 (PST) (Smail-3.2.0.114 2001-Aug-6 #1 built 2002-Sep-2) Date: Tue, 14 Jan 2003 17:05:56 -0800 Subject: Re: [Caml-list] Design question: functors or functions? Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) Cc: The Trade To: Brian Hurt From: james woodyatt In-Reply-To: Message-Id: <8047D54F-2825-11D7-B692-000393BA7EBA@wetware.com> Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.551) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Tuesday, Jan 14, 2003, at 13:57 US/Pacific, Brian Hurt wrote: > [...] The question I have is wether I should instead be > using a functor. The reason I haven't is that I find the functor > interface to be somewhat unwieldy, although maybe I just haven't gotten > used to it yet. [...] I have a similar set of functional data structures, e.g. red-black tree, skew-binary heap, catenable deque, etc., and I chose to use a functor for transforming modules that define a key type and an associated comparator function into modules that define the associated data structure. The reason: functions that take more than one instance of the data structure often depend on both instances using the same ordering function on the key type. The traditional way to get that is either with functors or with classes. My general philosophy is to prefer the lighter weight functors over classes, except when I really need inheritance or the easier method invocation syntax is a clear win. -- j h woodyatt ------------------- 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