develooper Front page | | Postings from September 2000

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

Thread Previous | Thread Next
Nathan Torkington
September 9, 2000 11:26
Re: RFC 82 (v3) Arrays: Apply operators element-wise in a list context
Message ID:
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.
> This RFC is absolutely fundamental to providing numeric programming
> capabilities in Perl 6, and it happens to make a lot of other stuff simpler
> besides (e.g. the text processing examples in the RFC). It would improve the
> speed and clarity of code, and Perl 5 scripts can be converted with a simple
> C<scalar>. I can't really see the argument for not doing this.

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


  @a = @b || @c;	# @a=@b or @a=@c;	# ish

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


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About