Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Lazy Arrays

6 views
Skip to first unread message

Luke Palmer

unread,
Jul 3, 2003, 6:51:41 PM7/3/03
to perl6-i...@perl.org
I'd like to go about implementing [Perl]?LazyArray and LazySequence
pmcs, possibly with a TiedArray (and Infinity) in the interim. I have
a few semantic questions, but first, here's what I have in mind:

LazySequence: Manages individual lazy sequences like 1..Inf (or
even 1..100_000)
LazyArray: Aggregates multiple lazy things together, along
with an "exceptions list" for things like:

@a = 1..Inf;
@a[6] = 42;

First, do these work well as pmcs, or should it be integrated with
PerlArray (I hope not)? Should Infinity be a pmc?

Any ideas on how these things should be set up at the assembly level?
I was thinking either:

$P0 = new LazySequence
$P1 = new Infinity
$P0["from"] = 0
$P0["to"] = $P1

or

$P0 = new LazySequence
$P1 = new Infinity
find_method P0, "set_range"
.arg 0 # Assuming imcc knows the new conventions
.arg $P1
invokecc

Finally, what should things like:

set $I0, $P0 # $P0 contains 1..Inf

Because integer registers can't well store infinity...

Thanks,
Luke

Benjamin Goldberg

unread,
Jul 4, 2003, 12:19:50 AM7/4/03
to perl6-i...@perl.org

This would probably have the same effect as:

$P1 = new Infinity
set $I0, $P1

Now, what *that* would do, I dunno... :)

Actually, I sortof do -- it should throw an exception of some sort.

--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}

Leopold Toetsch

unread,
Jul 4, 2003, 2:54:17 AM7/4/03
to Luke Palmer, perl6-i...@perl.org
Luke Palmer <fibo...@babylonia.flatirons.org> wrote:

> First, do these work well as pmcs, or should it be integrated with
> PerlArray (I hope not)?

It should subclass PerlArray. I think you don't need LazySequence. You
can just set the exceptions to the lazy sequence in the PerlArray
subclass.
Array/PerlArray can hold values for e.g.:

@a[0..1000, 1_000_000_000..1_000_001_000]

without growing to 1e9*x bytes.

> Should Infinity be a pmc?

Probably yes.

> Any ideas on how these things should be set up at the assembly level?
> I was thinking either:

Have a look at the initializer in list.c:list_new_init() or
classes/array.c:init_pmc() and the docs of init_pmc in pdd02.

> Finally, what should things like:

> set $I0, $P0 # $P0 contains 1..Inf

> Because integer registers can't well store infinity...

Through an exception.

> Thanks,
> Luke

leo

0 new messages