Hola, Some of us on #perl6 bitched once more about how lazy will make our IO brain hurt a lot.
The concensus is that a lazy context has not been discussed yet. Here is a proposal for lazyness defined with coroutines. we have a lazy modifier: my $a = lazy { get_value(5, 10) }; my @array = lazy gather { ... take ... }; What it returns is a proxy object that vivifies to a true value, or in the case of list context lazy, a proxy object array that implements a generator. The rvalue of the lazy context modifier is turned into a coro closure, and is invoked only when the value is accessed. Moreover, in lazy context, if the coro yields instead of finishing, then it is not finalized into a real value. Here's how the range operator would be implemented: sub &infix:<..> ($from, $to where { $to < $from }){ reverse $to .. $from } sub &infix:<..> ($from, $to) { lazy gather { while ($from <= $to) { take($from++); } }} In this case, take in lazy context gather would yield. The only "builtin" feature that needs to be added is that coroutines can masquerade as their return value, and not a code reference, but AFAIK proxy objects will give us that anyway, right? -- () Yuval Kogman <[EMAIL PROTECTED]> 0xEBD27418 perl hacker & /\ kung foo master: /me wields bonsai kittens: neeyah!!!!!!!!!!!!!!!!
pgpTt6lX8kOqt.pgp
Description: PGP signature