in reply to How to distinct the call position of a sub?
If your iterator cares about how and where it's being used, you basically prohibit all uses that you didn't think of, thus defeating the idea of code reuse.
The usual approach that you consider to be too verbose has the advantages that it
I think that ease of use on the one hand and ease of use on the other hand are not contradictory; one approach would be to use a tied array, so that you can iterate over it with a simple for loop.
Other ideas are to look on CPAN for lazy list implementations. (I've written Perl6::GatherTake as a proof of concept; it goes a bit in that direction, though I'm sure that you'll find much better suited modules).
I also think that if you ask broader, like "how do I write an iterator that's easy to use?" you might get even more clever ideas from the assembled monks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to distinct the call position of a sub?
by LanX (Saint) on Nov 24, 2008 at 23:28 UTC |