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 LAA05849; Wed, 2 May 2001 11:59:47 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA05996 for caml-list@pauillac.inria.fr; Wed, 2 May 2001 11:59:46 +0200 (MET DST) 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 CAA29849 for ; Wed, 2 May 2001 02:03:47 +0200 (MET DST) Received: from localhost.localdomain (ppp120.dyn146.pacific.net.au [210.23.146.120]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f4203j928693 for ; Wed, 2 May 2001 02:03:45 +0200 (MET DST) Received: from ozemail.com.au (IDENT:root@localhost [127.0.0.1]) by localhost.localdomain (8.9.3/8.8.7) with ESMTP id KAA29125; Wed, 2 May 2001 10:03:31 +1000 Message-ID: <3AEF4ED3.3A3C62E0@ozemail.com.au> Date: Wed, 02 May 2001 10:03:31 +1000 From: John Max Skaller X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.2.12-20 i686) X-Accept-Language: en MIME-Version: 1.0 To: Brian Rogoff CC: Mark Seaborn , caml-list@inria.fr Subject: Re: [Caml-list] two unrelated questions References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Brian Rogoff wrote: > > It's a pity there is no such destructor for a Hashtbl. > > [All C++ STL data structures have read iterators, which > > amount to destructors] > > Are they really the same? I think of STL style iterators as being more > similar to array indices, and arrays (and hashtables) are not defined > inductively like lists, trees, and graphs, etc. Well, for an iterator p, there are three operations: *p p++ p==q But they're usually combined like: *p++ which is equivalent to getting one element of the container p denotes, and adjusting p to denote the rest of the container. > As I'm sure you know, there is an easy enough transformation from > hashtables (and arrays) to lists, like the following > > let pairs_of_hashtbl ht = > let pl_ref = ref [] in > let fn a b = (pl_ref := (a,b)::(!pl_ref) in > (Hashtbl.iter fn ht; !pl_ref) Sure, but this requires building a new data structure. Even if that is OK for traversal, it can't handle mutating operations. Of course, people don't use STL algorithms as much in C++ as they might, because there is no support for nested anonymous functions (lambdas) or currying, which are essential for localisation. And of course Ocaml is _good_ at that :-) -- John (Max) Skaller, mailto:skaller@maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850 checkout Vyper http://Vyper.sourceforge.net download Interscript http://Interscript.sourceforge.net ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr