caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: John Max Skaller <skaller@ozemail.com.au>
To: Xavier Leroy <xavier.leroy@inria.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Hashtbl iter semantics
Date: Tue, 28 May 2002 04:16:29 +1000	[thread overview]
Message-ID: <3CF277FD.8070407@ozemail.com.au> (raw)
In-Reply-To: <20020527163853.A25103@pauillac.inria.fr>

Xavier Leroy wrote:

>>Could the ocaml team please clarify the semantics of Hashtbl.iter?
>>In particular, can I use Hashtbl.replace during iteration?
>>[What about add, removed, etc?]
>>
>
>You can use Hashtbl.{replace,add,remove} while iterating over the same
>hash table, in the sense that it will not corrupt the table.  However,
>there is no guarantee that the iteration will "see" the modification
>or not.  E.g. if you add an element, the function being iterated can
>be called on the newly added element, or not, depending on the
>relative positions of the new element and of the iteration point
>inside the hash table.
>
>If you need stronger guarantees 
>
No, I'd just like some text in the manual please, that I can use to
reason about the correctness of my algorithms.

For example, it isn't clear if I add a key, if the table might not
be reorganised so that 50 keys from the table are never presented.

The table isn't 'corrupted, though the scan pointer might be :-)
I guess nothing of the sort will happen with Hashtbl.iter.  

For example: delete: if  a binding is deleted it won't be presented 
subsequently.
Add: the binding may or may not be presented.
Replace:  if the binding is presented, it will have the data value used 
in replace.
If the binding was already presented, it will not be represented.
Otherwise: the binding will be presented with its initial data value.

-- 
John Max Skaller, mailto:skaller@ozemail.com.au
snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia.
voice:61-2-9660-0850




-------------------
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


  reply	other threads:[~2002-05-27 18:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-26 15:43 John Max Skaller
2002-05-27 14:38 ` Xavier Leroy
2002-05-27 18:16   ` John Max Skaller [this message]
2002-05-27 19:04 Damien Doligez
2002-05-29 19:01 ` John Max Skaller
2002-05-30  6:53   ` Francois Pottier
2002-05-31 17:29     ` John Max Skaller
2002-06-03  7:03       ` Francois Pottier
2002-06-03 17:07         ` John Max Skaller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3CF277FD.8070407@ozemail.com.au \
    --to=skaller@ozemail.com.au \
    --cc=caml-list@inria.fr \
    --cc=xavier.leroy@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).