develooper Front page | perl.perl6.language.data | Postings from September 2000

Re: RFC 82 (v3) Arrays: Apply operators element-wise in a list context

Thread Previous | Thread Next
From:
Jeremy Howard
Date:
September 9, 2000 15:01
Subject:
Re: RFC 82 (v3) Arrays: Apply operators element-wise in a list context
Message ID:
003d01c01aa9$92ceb770$d5252ccb@optimaldecisions.com
Nathan Torkington wrote:
> Jeremy Howard writes:
> > No, there's no arbitrary decision. *Every* operator is component wise on
> > lists. It is internally consistent, and consistent with most other
languages
> > that provide array/list operators. It's easy to get stuck on the '*'
> > example, because different mathematicians have different feelings about
what
> > matrix operation should map to '*'. However, there is no consistant and
> > meaningful definition of array operations (for _all_ operators) other
than
> > that defined in RFC 82.
> >
> Actually, the only refinement I'd like to see is that boolean operators
> (==, &&, ||) be excepted from the distributive rule.
>
> This is to permit:
>
>   if (@a == @b) # shallow comparison

Already works under the RFC (scalar context).
>
> and
>
>   @a = @b || @c; # @a=@b or @a=@c; # ish
>
Doesn't work in P5 (try it!)

> The math operations are fine to apply to each element.  I have no
> problem with those being distributive, but I think || for default
> values and == for comparison are too ingrained and they'd be too
> useful (as opposed to a distributive || or &&, which is much less
> useful).
>
== is applied in a scalar context--fine. || as you show it can not be
ingrained because it doesn't currently work this way!



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About