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 XAA15540; Fri, 23 Apr 2004 23:53:37 +0200 (MET DST) 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 XAA15438 for ; Fri, 23 Apr 2004 23:53:36 +0200 (MET DST) Received: from gatekeeper.elmer.external.excelhustler.com (gatekeeper.excelhustler.com [68.99.114.105]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i3NLrZYM017687 for ; Fri, 23 Apr 2004 23:53:35 +0200 Received: from chatterbox.elmer.internal.excelhustler.com (unknown [192.168.0.12]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (Client CN "chatterbox.elmer.internal.excelhustler.com", Issuer "excelhustler.com" (not verified)) by gatekeeper.elmer.external.excelhustler.com (Postfix) with ESMTP id B221DE013F; Fri, 23 Apr 2004 16:53:34 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by chatterbox.elmer.internal.excelhustler.com (Postfix) with ESMTP id F0C5C5C006; Fri, 23 Apr 2004 16:53:33 -0500 (CDT) Received: from wile.internal.excelhustler.com (wile.internal.excelhustler.com [192.168.1.34]) by chatterbox.elmer.internal.excelhustler.com (Postfix) with ESMTP id C5DCE5C005; Fri, 23 Apr 2004 16:53:33 -0500 (CDT) Received: by wile.internal.excelhustler.com (Postfix, from userid 1000) id BFAAD704F; Fri, 23 Apr 2004 16:53:33 -0500 (CDT) Date: Fri, 23 Apr 2004 16:53:33 -0500 From: John Goerzen To: Jon Harrop Cc: caml-list@inria.fr Subject: Re: [Caml-list] Should be INSIDE STANDARD-LIB: Hashtbl.keys Message-ID: <20040423215333.GI6783@excelhustler.com> References: <20040421011904.GA1411@first.in-berlin.de> <20040423180407.A20341@pauillac.inria.fr> <200404231921.45227.jdh30@cam.ac.uk> <200404232231.36872.jdh30@cam.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200404232231.36872.jdh30@cam.ac.uk> User-Agent: Mutt/1.5.5.1+cvs20040105i X-Scanned-By: clamscan at chatterbox.elmer.internal.excelhustler.com X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 hashtbl:01 2004:99 quux:01 hash:01 hash:01 up-front:99 configuring:01 configuring:01 filenames:01 ruby:02 isp:96 wrote:03 data:03 mapping:05 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, Apr 23, 2004 at 10:31:36PM +0100, Jon Harrop wrote: > I should also say that I have never had any need for this function. What do > you guys use it for? One example is the sections function at http://gopher.quux.org:70/devel/missinglib/html/ConfigParser.rawConfigParser.html. Internally, a configuration file is represented as a hash of section names to a hash of option names to values. (A hash of a hash of strings, basically.) Sometimes, you might not know what sections to expect up-front. Getting a list of the keys in the top-level hash will return the needed information. This could occur for many reasons: configuring multiple ISP accounts in a network tool, configuring multiple database sources in an ODBC configuration, etc. Here's a contrived example, but one I could imagine encountering: Having a hash mapping filenames to data about them (say, from stat(2). Perhaps you'd have a need sometimes to just get a list of files (maybe to copy them elsewhere or display a list for the user). Yes, one could use fold to do all of this. Point is, it's often easier to just call "keys" and get a list. The raw performance may not always matter. (Just witness the popularity of Ruby ) -- John ------------------- 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