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.  Built-in
addition will have an identity value of 0, while multiplication will
have an identity value of 1.  String concatenation will have "".
We can go as far as having -Inf on [<] and +Inf on [>], but maybe
that means we have to define values that are positive and negative
infinity on strings so we can get [gt] and [lt] indentity values.
Those might be useful in any event.

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.
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".

Larry

Reply via email to