Right.  So,

my $foo = 1..*;
$foo.max;

Should return Inf; likewise

my @foo = 1...*;
@foo.max;

Should behave like

(1...*).max

...that is, I expect both not to terminate.  It's the conversion to
array that is the break in the original example, not the act of
assigning to a variable.

This .. vs ... stuff is going to be a continuous source of confusion, I fear.

On Friday, July 30, 2010, Patrick R. Michaud <pmich...@pobox.com> wrote:
> On Fri, Jul 30, 2010 at 01:22:02PM -0400, Mark J. Reed wrote:
>> What is assigning a Range to an array supposed to do?  Give you an
>> array of one item which is a Range?  Convert to a series?
>
> A range in list context becomes a list of successive values in
> the Range.
>
>     my @foo = 1..*;
>
> causes @foo to be initialized (lazily, as requested) to 1, 2, 3, and
> on up to infinity. �...@foo.max then tries to find the maximum value
> of @foo, which takes a very long time as the .max method goes through
> the infinite set of elements of @foo looking for the largest one to
> return.
>
> It's possible that C<.max> should detect that its invocant has
> an infinite number of elements and return a failure of some sort,
> but I'd want a consensus opinion on it before doing it.
>
> Pm
>
>> On Friday, July 30, 2010, Will Coleda <perl6-bugs-follo...@perl.org> wrote:
>> > # New Ticket Created by  Will Coleda
>> > # Please include the string:  [perl #76842]
>> > # in the subject line of all future correspondence about this issue.
>> > # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=76842 >
>> >
>> >
>> > twitterbugged @ http://twitter.com/mfollett/status/19919694472 :
>> >
>> > - Interesting Rakudo edge case: > (1..*).max Inf But: > my @foo = 1..*
>> >> @foo.max doesn't finish, yet
>> >
>> > --
>> > Will "Coke" Coleda
>> >
>>
>> --
>> Mark J. Reed <markjr...@gmail.com>
>

-- 
Mark J. Reed <markjr...@gmail.com>

Reply via email to