# New Ticket Created by  Zefram 
# Please include the string:  [perl #126146]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=126146 >


The reduce metaoperator iterates through its list of operands in a
way that will be prematurely terminated if the IterationEnd sentinel
appears in the list.  This is trivially demonstrated by reducing over
list construction, which ought to amount to list copying:

$ ./perl6 -e 'say ([,] 2, 3, 4, 5, 6).perl'
(2, 3, 4, 5, 6)
$ ./perl6 -e 'say ([,] 2, 3, IterationEnd, 5, 6).perl'
(2, 3)

Obviously, being a public object that's part of the Iterator API, this can
in general appear in a user's list.  The sentinel wouldn't normally be
used as an operand for the kind of operations one would stereotypically
reduce over, but it does have well-defined behaviour for such operators,
which is lost by the premature list termination:

$ ./perl6 -e 'say 2 * IterationEnd'
X::Multi::NoMatch exception produced no message
  in block <unit> at -e:1
$ ./perl6 -e 'say ([*] 2, IterationEnd, 3)'
2

-zefram

Reply via email to