Index

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


NAME

Notes on Range implementation

SYNOPSIS

A Range is a lazy iterator with a starting, iterating, and stopping condition.

DESCRIPTION

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:

NumRange
The classic numeric range, 1 .. 10 and all that it implies.
StrRange
The range of strings, a .. z. Probably pretty obvious, but might be a little trickier in the presence of unicode. We will see.
RepeatRange

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:

MapRange
When the 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 :)
GrepRange
The same logic and reasoning which applies to MapRange, applies here.
ReverseRange
This may not be needed, it may be easy enough to just swap the start condition, for the end condition, but we will see.

LARRY SAYS

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 }

SEE ALSO

docs/notes/laziness.txt

perl5/Perl6-(Value|Container)

AUTHOR

Stevan Little <stevan@iinteractive.com>