This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Scheme style auto-resizing hashtable (fwd)


Per Bothner <bothner@cygnus.com> writes:

 > A simple Scheme-style iterator:
 > 
 > (hash-key-iterator HASHTABLE) -> ITERATOR
 > 
 > where ITERATOR is a zero-argument procedure whose first call
 > returns the first key, the second call returns the next key,
 > and so on.  When there are no more elements, an end of file
 > object is returned.

What does the iterator do if the hashtable is modified before it's
gotten to the end?

For that matter, what do map & for-each do if the lists they're
mapping over are modified before they reach the end?

It's just that in your example the iterator is explicitly returned,
making it more likely for it to be passed around & used out of scope,
whereas with map & for-each the lists in question are typically out of
the scope of the fcns mapping over them, so accidental modification is
more likely.

In any case, Henry Baker has a nice paper about how mapping is where
it's at & how iterators are just a weak add-in to a broken language.

-- 
Harvey J. Stein
BFM Financial Research
hjstein@bfr.co.il