* Peter Corlett <ab...@cabal.org.uk> [2012-05-14 12:20]:
> On Mon, May 14, 2012 at 11:06:59AM +0200, demerphq wrote:
> > I kinda wish perl had an interface like
>
> > my $iter= iterator(%hash);
> > while (my ($key,$value)= $iter->each) { }
>
> > Which I think would be sane. You could even pass the iterator
> > without passing the hash itself. (Preventing modifications to the
> > hash but allowing 3rd party code to iterate it).
>
> I suspect it would be relatively simple to write a module to provide
> that syntax.

6 lines for the most minimal pure-Perl implementation. But to really do
it right (i.e. not eat memory for a copied key list) requires access to
the hash data structure at a level that AFAIK requires XS.

Reply via email to