Okay, I've made up my mind. The "err" option is not tenable because it can cloak real exceptions, and having multiple versions of reduce is simply multiplying entities without adding much power. So let's allow an optional "identvalue" trait on operators. If it's there, reduce can use it. If it's not, reduce returns failure on 0 args.
So, just to clarify, for the expression: [op] @list if C<op> has an C<:identval> trait then the result is: * &op.identval() if @list == 0 * @list if @list == 1 * @list op @list op...op @list[-1] if @list > 1 Otherwise the result is: * fail if @list == 0 * @list if @list == 1 * @list op @list op...op @list[-1] if @list > 1 Correct?
But I would like to stress that this is an *optional* property. We will only define an identity value for those operators for which it is obvious what an "accumulator" should be initialized to. (This is probably also the set of operators for which op= doesn't warn when the left side is undefined, so "identval" is doing double duty.
So, to clarify again, if $var is undefined, then the assignment: $var op= $value; is equivalent to: $var = (&op.does(identval) ?? &op.identval() :: undef) op $value; Correct?
In Perl 5 we hardwired that, so it'd be nice to generalize the concept in Perl 6.)
In fact, by the accumulator argument, maybe it should be called "initvalue" rather than "identvalue".
I'd be very leery of calling it "initvalue", since people are apt to confuse it with real initialization. I'd be inclined to call it "identityval" and simply say that an undefined variable that is op-assigned defaults to the identity value of the operator (if any).