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=HTML_MESSAGE autolearn=disabled version=3.1.3 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id AD336BBCA for ; Sun, 11 May 2008 16:44:16 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgcDAEujJkjAXQImiGdsb2JhbACCNzSPHgEBAQ8gkmSEHw X-IronPort-AV: E=Sophos;i="4.27,469,1204498800"; d="scan'208";a="10597938" Received: from discorde.inria.fr ([192.93.2.38]) by mail2-smtp-roc.national.inria.fr with ESMTP; 11 May 2008 16:44:16 +0200 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m4BEiFV5012302 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Sun, 11 May 2008 16:44:16 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmcEANOiJkhIDtycc2dsb2JhbACCNzSPHgEMAwQECQ8FkmGEHw X-IronPort-AV: E=Sophos;i="4.27,469,1204498800"; d="scan'208";a="26049648" Received: from fg-out-1718.google.com ([72.14.220.156]) by mail4-smtp-sop.national.inria.fr with ESMTP; 11 May 2008 16:44:15 +0200 Received: by fg-out-1718.google.com with SMTP id e21so1539490fga.25 for ; Sun, 11 May 2008 07:44:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=9TWbwzK44r9u0cRp9WudGjN0/1Ix/KytPBfkq/W4QKw=; b=sE0Gn65YqqMCXg9d+oWtBG1jRa+5RKrcQ37vW5G+otJVJJ59gFhIhe93tqSL44GHsHs9EDK9qiWuUEGQrMWJ7kAowydsbkmQuqUGEMJdXMDQfQC7CuOIQyAyr1ej9rQT6BebH2OU8p6hshPokJMJo4T9jS8pM0jFHx8sugfi5iE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=L4BbCmQwDz93m1Z1pu8XjiVpsMk9ncbvlydCscfIYmcwkAZUolG1InnHpDrHp874p3HHP9NXprYpa5Kf0MkqBsuM1aPLaFQcxiC35VXhnTpJtSv50e7Pvey3loXCvWFFxfszwzDXovEVW139rKDqvPQ+EQm7LeZT1TG5vAS5Pl0= Received: by 10.86.87.13 with SMTP id k13mr12472603fgb.1.1210517054271; Sun, 11 May 2008 07:44:14 -0700 (PDT) Received: by 10.86.96.19 with HTTP; Sun, 11 May 2008 07:44:14 -0700 (PDT) Message-ID: <9b73ffc50805110744k6da17eb9yd40231d9e8c31787@mail.gmail.com> Date: Sun, 11 May 2008 16:44:14 +0200 From: "Julien Peeters" To: "David MENTRE" , caml-list@inria.fr Subject: Re: [Caml-list] Hashtbl.remove legal within Hashtbl.iter for the same hash table? In-Reply-To: <87tzh5kxhl.fsf@linux-france.org> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_385_22079597.1210517054258" References: <87tzh5kxhl.fsf@linux-france.org> X-Miltered: at discorde with ID 4827063F.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; hashtbl:01 hashtbl:01 iter:01 hash:01 iter:01 hash:01 gpg:01 beginner's:01 ocaml:01 bug:01 paris-sud:01 orsay:01 gpg:01 beginner's:01 ocaml:01 ------=_Part_385_22079597.1210517054258 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi David, Because the arguments passed to functions could be considered as references (same memory space), IMHO, if you respect the scope priority it should work= . For instance: let () =3D let h =3D Hashtbl.create 7 in let f k v =3D Hashtbl.remove h k in Hashtbl.iter f h Julien. 2008/5/11 David MENTRE : > Hello, > > Probably a newbie question but anyway: is it allowed to do a > Hashtbl.remove while doing a Hashtbl.iter on the same hash table? > > More precisely, at one point while doing a "Hashtbl.iter f h" my > function "f" is called with something like "f k v". Can I do a > "Hashtbl.remove h k" within the body of "f"? > > Sincerely yours, > david > -- > GPG/PGP key: A3AD7A2A David MENTRE > 5996 CC46 4612 9CA4 3562 D7AC 6C67 9E96 A3AD 7A2A > > _______________________________________________ > 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 > --=20 Julien Peeters Student in engineering Institut de Formation des Ing=E9nieurs de Paris-Sud Orsay, France Website: http://www.dedilabs.com/~jpeeters ------=_Part_385_22079597.1210517054258 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi David,

Because the arguments passed to functions could be conside= red as references (same memory space), IMHO, if you respect the scope prior= ity it should work.

For instance:

let () =3D
  &= nbsp; let h =3D Hashtbl.create 7 in
    let f k v =3D Hashtbl.remove h k in
   = ;     Hashtbl.iter f h

Julien.

2008/5/11 David MENTRE <dmentre@linux-france.org>:
Hello,

Probably a newbie question but anyway: is it allowed to do a
Hashtbl.remove while doing a Hashtbl.iter on the same hash table?

More precisely, at one point while doing a "Hashtbl.iter f h" my<= br> function "f" is called with something like "f k v". Can= I do a
"Hashtbl.remove h k" within the body of "f"?

Sincerely yours,
david
--
GPG/PGP key: A3AD7A2A David MENTRE <dmentre@linux-france.org>
 5996 CC46 4612 9CA4 3562  D7AC 6C67 9E96 A3AD 7A2A

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.in= ria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs



--
Julien Peeters
Stude= nt in engineering
Institut de Formation des Ing=E9nieurs de Paris-SudOrsay, France
Website: ht= tp://www.dedilabs.com/~jpeeters ------=_Part_385_22079597.1210517054258--