>>>>> "TH" == Tom Hughes <[EMAIL PROTECTED]> writes:
TH> In other words, it's just a generic iterator state object... The
TH> way I'd like to see things work is that hashes, arrays etc have a
TH> vtable method that returns an iterator object. That iterator object
TH> then has whatever opaque data is needed to maintain position plus
TH> it's own vtable that can advance the iterator, return the current
TH> value, etc. So we get something like this:
TH> it = hv->new_it()
TH> while (it->valid())
TH> {
TH> sv = it->value();
TH> ...
it-> next();
TH> }
TH> If iterators are (internally) first class objects like this then
TH> they can be used in places where arrays are otherwise used - if an
TH> iterator is found where an array is expected it is simply advanced
TH> to completion to recover the values to operate on. Of course this
TH> can, where possible, be done lazily.
that is what i was thinking about with external iterators. they are
generic but can use the lower type to get the next thing or the current
value.
but you can't modify the lower structure as it can/will confuse the
iterator. a splice in an array around the current location or a hash
addition which causes a full rehash would blow these up.
but with these you can do a double loop over a hash without each blowing
up. and that is wanted by many.
uri
--
Uri Guttman --------- [EMAIL PROTECTED] ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com