Mark Cogan wrote:
> At 05:47 PM 8/15/00 -0600, 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.
>
> Seconded.
>
> It seems obvious that @a should be the whole array @a, not an iteration
> over its elements. If I want to iterate over @a, I should have to do so
> explicitly, with a for() or map().

It seems obvious that @a should be the whole array @a, not the size of the
array. If I want to check the size of @a, I should have to do so explicitly,
with scalar or $#.

This is non-obvious if you think that || is a flow control statement, so
think about * for a moment:

  @c = @b * @a;

It's pretty clear what working on 'the whole array' means here, I think.
Treating || as a special case is asking for trouble. If you want a flow
control statement, use one:

  @result = @b unless @result = @a;


Reply via email to