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 IAA05438; Wed, 17 Oct 2001 08:29:17 +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 IAA05412 for ; Wed, 17 Oct 2001 08:29:16 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f9H6TDT00790 for ; Wed, 17 Oct 2001 08:29:14 +0200 (MET DST) Received: from localhost (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3/3.7W) with ESMTP id PAA18577; Wed, 17 Oct 2001 15:28:54 +0900 (JST) To: maya@dsl.serc.iisc.ernet.in Cc: caml-list@inria.fr Subject: Re: [Caml-list] Hashtbl.iter In-Reply-To: References: X-Mailer: Mew version 1.94.2 on Emacs 20.7 / Mule 4.0 (HANANOEN) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20011017152854F.garrigue@kurims.kyoto-u.ac.jp> Date: Wed, 17 Oct 2001 15:28:54 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: Maya Ramanath > The question is with regard to Hashtbl.iter. Basically, what happens when > I'm doing an iteration on the Hashtbl and at the same time add something > new to the hashtable ? For ex: > let xyz ht key value = > (* Do something with key, value *) > if (some-condition-holds) then > ht.add something new > > let abc ht = > Hashtbl.iter (xyz ht) ht > > I would like to know if the new things that I added to the hashtable will > be picked up by the iterator. If you look at the source in hashtbl.ml, clearly the answer is "undefined behaviour". If your new element is added in a bucket after the one your are currently processing then yes, otherwise no, and the point of hashtables is that you don't know in which bucket you will end up... If you want to avoid this behaviour, use Map.Make. Jacques Garrigue ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr