>>>>> "DLN" == David L Nicol <[EMAIL PROTECTED]> writes:

  DLN> "David L. Nicol" wrote:

  >> > In perl 6 the keys and values functions should no longer use the
  >> > same iterator as the each function - each use of keys and values
  >> > should use it's own private iterator instead.

  DLN> we could put it in a variable associated with the instance of the
  DLN> keyword.  An associative array of threads to current-values.

this can be done just the way .. maintains its own state value. so
keys/values/each would have a private iterator that gets initialized
from the hash. but a problem is how do you reset that iterator they way
scalar keys resets it now for the single iterator of a hash? i don't see
any obvious syntax that we can apply to the keys expression to reset
it. maybe we need an iterator object which is used for this. how about
an iter function that creates an iterator?

        $foo_iter = iter %foo ;

        while ( $key = $foo_iter->key() ) {

        foreach $key ( $foo_iter->keys() ) {

those two are exactly the same. keys is an HOF which is lazy. it behaves
like singular key but in a list context so it returns the next key in
each iteration of the for loop.

        while ( ( $key, $val ) = $foo_iter->each() ) {

        reset $foo_iter ;

what happens if you modify the hash when you have an iterator? also we
have to require the iteration order to be fixed for a given hash which
is not modified so slices and such will remain synchronized.

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

Reply via email to