Nathan Torkington wrote:
> Jeremy Howard writes:
> > @result = @a || @b;
> >
> > Which applies '||' component-wise to elements of @a and @b, placing the
> > result in @result.
>
> *Ptui* That's not how *I* want || to behave on lists/arrays.
>
> I want
> @result = @a || @b;
> to be like:
> (@result = @a) or (@result = @b);
>
> That's what all my students keep expecting it to mean.
>
Note that RFC 82 (http://tmtowtdi.perl.org/rfc/82.pod) proposes that _all_
operators behave the same way in a list context. To me, this consistancy
would be a real win.
The behaviour you're discussing is described in RFC 45. RFC 45 proposes a
special case for the || operator, which is only using its short-circuiting
functionality, not its 'or' functionality. In this case I would think that
using an explicit 'if' would be more appropriate. I'm working with the
maintainer of RFC 45 at the moment to see if we can get the consistency of
component-wise behaviour in a list context without losing the ability to
short-circuit in an assignment.
A potential compromise would be to say that RFC 82 only applies to operators
that do not short-circuit. However, my view is that the loss of consistency
through such a step would be a substantial source of confusion. It would
also mean that overloaded operators with a lazily evaluated parameter would
not work in a consistent manner.