Skip to content

Commit 6f34dd5

Browse files
committed
last from ...* must change .elems to finite
1 parent 12a2ea6 commit 6f34dd5

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

S03-operators.pod

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Synopsis 3: Perl 6 Operators
1515

1616
Created: 8 Mar 2004
1717

18-
Last Modified: 27 Feb 2012
19-
Version: 239
18+
Last Modified: 28 Feb 2012
19+
Version: 240
2020

2121
=head1 Overview
2222

@@ -2141,8 +2141,7 @@ eager' list, any sequence that terminates with an exact value (or
21412141
that starts another sequence with exact values) is considered finite,
21422142
as is any sequence that has an explicit ending closure.
21432143
However, any sequence that ends C<*> is considered to be of unknowable
2144-
length (even if generated with a closure that has internal logic to
2145-
terminate). However, by the definition of "mostly eager" in L<S07>,
2144+
length. However, by the definition of "mostly eager" in L<S07>,
21462145
the implementation may be able to determine that such a sequence is
21472146
finite by conjectural evaluation; such workahead cannot, of course,
21482147
prove that a sequence is infinite without running a Very Long Time.
@@ -2161,6 +2160,12 @@ infinite list in contexts which care. Similarly, any list ending
21612160
with an operator that interprets C<*> as infinity may be taken the
21622161
same way, such as C<$n xx *>, or C<1..*>.
21632162

2163+
On the other hand, it's possible to write a sequence that appears to be
2164+
infinite, but is terminated by a C<last> from the iterator closure. An
2165+
implementation is required to trap such a loop termination and change the
2166+
status of the list from 'infinite' to 'finite, such that C<.elems> reports
2167+
the actual produced length, not C<Inf>.
2168+
21642169
=item *
21652170

21662171
C<< infix:<E> >>, test for EMPTY iterator

0 commit comments

Comments
 (0)