Do you know where your variables are? | |
PerlMonks |
Any thoughs on Iterator prefetching?by mzedeler (Pilgrim) |
on Jun 25, 2009 at 13:11 UTC ( [id://774712]=perlquestion: print w/replies, xml ) | Need Help?? |
mzedeler has asked for the wisdom of the Perl Monks concerning the following question: Hi fellow perl monks. I have had a nasty surprise when I discovered that Iterator prefetches values when instantiated. This causes non-pure functions to behave very, very strange. E.g.:
This SHOULD print:
But it does in fact print this:
It seems that the author of Iterator wants it to contain a buffer of one value, but I have a very hard time understanding why. Could someone please enlighten me? Here is an even more degenerate example using chained iterators:
This SHOULD print:
But it prints this:
The strange behavior can be explained off when you consider the prefetch buffer, but it is very hard to use in practise. RT for the module contains two reports regarding this, (I posted one of them): Please let me know if there is any reasonable explaination for this behaviour. Regards, Michael Zedeler (MADZ).
Back to
Seekers of Perl Wisdom
|
|