Skip to content

Commit e0b271a

Browse files
authored
Document edge case eqv behaviour…
…when comparing lazy iterables
1 parent 6dc61f8 commit e0b271a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

doc/Language/operators.pod6

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,6 +1529,16 @@ the same, i.e. from the same type and (recursively) contain the same values.
15291529
say 1 eqv 2; # OUTPUT: «False␤»
15301530
say 1 eqv 1.0; # OUTPUT: «False␤»
15311531
1532+
Note that lazy L«C<Iterables>|/type/Iterable» cannot be compared, as
1533+
they're assumed to be infinite. However, the operator will do its best and
1534+
return C<False> if the two lazy C<Iterables> are of different types or
1535+
if only one C<Iterable> is lazy.
1536+
1537+
say (1…∞) eqv (1…∞).List; # Both lazy, but different types; OUTPUT: «False␤»
1538+
say (1…∞) eqv (1…3); # Same types, but only one is lazy; OUTPUT: «False␤»
1539+
(try say (1…∞) eqv (1…∞)) # Both lazy and of the same type. Cannot compare; throws.
1540+
orelse say $!.^name; # OUTPUT: «X::Cannot::Lazy␤»
1541+
15321542
The default C<eqv> operator even works with arbitrary objects. E.g., C<eqv>
15331543
will consider two instances of the same object as being structurally
15341544
equivalent:

0 commit comments

Comments
 (0)