On Tue, Sep 09, 2008 at 10:10:04AM -0500, Patrick R. Michaud wrote: : I think my question can be best understood by example -- what : does the following produce? : : my @a = 1,2,3,4,5; : for @a { .say; @a = (); } : : My question is whether the change to @a inside the for loop : affects the iterator created at the beginning of the for loop. : In other words, would the above produce "1\n2\n3\n4\n5\n" or : "1\n" ? : : My followup question is then: : : my @a = 1,2,3,4,5; : my @b = 6,7,8; : : for @a,@b { .say; @b = (); } : : I have more examples involving various aspects of list and : iterator semantics, but the answers to the above will help guide : my questions.
At the moment the design of Perl 6 (unlike certain FP languages) is that any dependence on the *degree* of laziness is erroneous, except insofar as infinite lists must have *some* degree of laziness in order not to use up all your memory immediately. But any finite list can do any amount of batching it pleases, so there's no foolproof way to tell a lazy finite list from an eager list. Modifying the inputs to a lazy list is basically asking for undefined behavior. This seems to me like the most multicore-friendly default, though perhaps not the most programmer friendly. It seems to me that any programming involving cyclic lazy feeds must somehow have an "eager" in it somewhere to prevent indeterminacy, but I don't know how to write a compiler that enforces that offhand. Larry