From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id C10B4BBCA for ; Mon, 12 May 2008 01:10:23 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArQAAC4ZJ0hCbwQZmWdsb2JhbACSDAEBAQEBCAUGCRGXAg X-IronPort-AV: E=Sophos;i="4.27,470,1204498800"; d="scan'208";a="12106651" Received: from out1.smtp.messagingengine.com ([66.111.4.25]) by mail1-smtp-roc.national.inria.fr with ESMTP; 12 May 2008 01:10:23 +0200 Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id AE4611069E1; Sun, 11 May 2008 19:10:21 -0400 (EDT) Received: from heartbeat2.messagingengine.com ([10.202.2.161]) by compute1.internal (MEProxy); Sun, 11 May 2008 19:10:21 -0400 X-Sasl-enc: vp4WkrjWhRgFFHoWqp4DmAns/LcHSd+jHDi3UJp5wTSg 1210547420 Received: from [192.168.1.10] (ALyon-157-1-90-71.w90-41.abo.wanadoo.fr [90.41.73.71]) by mail.messagingengine.com (Postfix) with ESMTPSA id 544CD22E18; Sun, 11 May 2008 19:10:20 -0400 (EDT) Date: Mon, 12 May 2008 01:08:08 +0200 (CEST) From: Martin Jambon X-X-Sender: martin@martin.ec.wink.com To: Till Varoquaux Cc: Florent Monnier , caml-list@yquem.inria.fr Subject: Re: [Caml-list] Hashtbl.remove legal within Hashtbl.iter for the same hash table? In-Reply-To: <9d3ec8300805111545y34eccd27mb00187f23e779610@mail.gmail.com> Message-ID: References: <87tzh5kxhl.fsf@linux-france.org> <200805111642.14164.fmonnier@linux-nantes.fr.eu.org> <9d3ec8300805110746s3b4ad089p9d6572a491403384@mail.gmail.com> <200805111710.06994.fmonnier@linux-nantes.fr.eu.org> <9d3ec8300805111545y34eccd27mb00187f23e779610@mail.gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Spam: no; 0.00; ens-lyon:01 hashtbl:01 hashtbl:01 iter:01 hash:01 iter:01 ocaml's:01 arrays:01 associative:01 iterating:01 bindings:01 unspecified:01 beginner's:01 ocaml:01 bug:01 On Sun, 11 May 2008, Till Varoquaux wrote: > Indeed. The answer you got was, however, based on the actual > implementation not on the documentation. This means that, at some > point, this might evolve and not be valid anymore. If you want to be > on the safe side you should do a fold instead of an iter and collect > all of the items to remove and then remove them in a second pass. The > performance hit shouldn't be as bad as you could expect (ie: I > wouldn't bother unless performance really is critical). > I see it as very unlikely that ocaml's implementation of hashtbl would > evolve in such a way that it would break any code removing previously > visited items during a traversal. Your call. If you (Florent) want to rely on the standard Hashtbl module, I would strongly advise against making assumptions such as "the implementation is unlikely to change". Think of the situation 5 years later, when the implementation actually changes, you've left the company 3 years before, and the maintainer has to figure why the program returns messed up results... I bet you wouldn't like to be this maintainer. It's like drunk driving or forgetting the condom: just don't do it... Martin > On 5/11/08, Florent Monnier wrote: >>> Hatables are arrays of associative lists. When you are iterating over >>> them removing any element you have already visited should be ok. >>> Removing elements you haven't visited yet could cause you to encounter >>> them anyhow. >> >> which means that it is dependent to the order in which the content is >> itered, >> while the manual says : >> "The order in which the bindings are passed to f is unspecified." >> >> _______________________________________________ >> Caml-list mailing list. Subscription management: >> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list >> Archives: http://caml.inria.fr >> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners >> Bug reports: http://caml.inria.fr/bin/caml-bugs >> > > > -- > http://till-varoquaux.blogspot.com/ > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > -- http://wink.com/profile/mjambon http://mjambon.com