On Mon, Dec 06, 2004 at 06:14:56PM -0500, Austin Hastings wrote:
: Luke Palmer wrote:
: 
: >Larry Wall writes:
: > 
: >
: >>Any foo() can return a list.  That list can be a Lazy list.  So the
: >>ordinary return can say:
: >>
: >>   return 0...;
: >>
: >>to return an infinite list, or even
: >>
: >>   return 0..., 0...;
: >>   
: >>
: >
: >Is it just me, or did you just return ω*2?  
: >http://en.wikipedia.org/wiki/Ordinal#Arithmetic_of_ordinals
: >
: >That would be totally cool.  But um, how do we get at the structure of
: >that list from within Perl?  It looks like no matter what you do it
: >would be impossible to see the second 0.
: >
: >Luke
: >
: > 
: >
: my ($foo1, $foo2) = foo();
: 
: ?

No, that'd put 0 and 1 into those variables.

You'd have to bind the return value to @foo and then ask @foo for its
hidden specs that generates its values.  That has two elements, one for
each infinite iterator.  Here's the quote from A6:

    The List type in particular is an internal type for the temporary
    lists that are passed around in Perl. Preflattened lists are Eager,
    while those lists that are not preflattened are Lazy. When you call
    @array.specs, for instance, you actually get back an object of type
    Lazy. Lists (Lazy or otherwise) are internal generator objects,
    and in general you shouldn't be doing operations on them, but on
    the arrays to which they are bound. The bound array manages its
    hidden generators on your behalf to "harden" the abstract list
    into concrete array values on demand.

As far as I can recall we haven't renamed C<.specs> to anything else yet.

Larry

Reply via email to