Angel Faus wrote:

I understand that this formulation is more powefull, but one thing I like
about python's way (where a coroutine is just a funny way to generate lazy
arrays) is that it lets you _use_ coroutines without even knowing what they
are about.

Such as when you say:

for $graph.nodes { ... }

.nodes may be implemented as a coroutine, but you just don't care about it.
Plus any function that previously returned an array can be reimplemented as
coroutine at any time, without having to change the caller side.
Yes, it may be that Pythonic -- as opposed to Satherian/CLUic -- iterators are
a better fit for Perl 6. It rather depends on the semantics of Perl 6
iterators, which Larry hasn't promulgated fully yet.


In other words, how do you create a lazy array of dynamically generated
values in perl6?

Maybe it could be something like this:

 $foo = &bar.instantiate(1, 2, 3);
 @array = $foo.as_array;
Well, I think it has to be much less ugly than that! ;-)


Damian

Reply via email to