This file was automatically generated from http://svn.pugscode.org/pugs/docs/notes/range_implementation_notes.pod on Wed Jun 6 22:16:47 2007 GMT, revision 16639.
Notes on Range implementation
A Range is a lazy iterator with a starting, iterating, and stopping condition.
The Range API will be specified using a role, but there will be a number of class implementations which do that role.
There are basic "front-end" range classes, which are:
1 .. 10 and all that it implies.
a .. z. Probably pretty obvious, but might be a little
trickier in the presence of unicode. We will see.
A range of repeated things, 1 xx 10. This is useful for initializing
data structures:
@a[0..999] = -1 xx 1000;
The other classes will be private or inner classes to the "front-end" Range clases, and those are:
map(CODE) method is called on a Range object, we need to preserve the
original Range, and only apply the CODE object to each element after it has
been generated. This could probably be accomplished with some closure acrobatics,
but a seperate classe helps to preserve KISS :)
If you say
$r = 1..10;
you are intentionally putting the range object in a place where you have to explicitly iterate it, so in list context you'd have to say
for =$r { say }
docs/notes/laziness.txt
perl5/Perl6-(Value|Container)
Stevan Little <stevan@iinteractive.com>