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:
Nathan Wiger
Date:
September 9, 2000 13:33
Subject:
Re: RFC 82 (v3) Arrays: Apply operators element-wise in a list context
Message ID:
39BA9C99.C43906EE@wiger.org
c.soeller@auckland.ac.nz wrote:
> 
> I disagree. You end up with a situation where some
> 
>    @a * @b;
> 
> are in scalar context, some not.

No, everything would be in a scalar context. If you used tie() to
specially tie a variable, then you might be able to overload +, *, -,
etc, but this is no different from overloading other objects, which you
can do currently.

> And what happens when you say
> 
>    @a = (1,2,2);
>    @b = tie Matrix (1,2,3);
> 
>    @a*@b;
> 
> Who wins?

There are already well-established precedence rules on operator
overloading; check out the Camel-3 chapter on it. The methods proposed
in RFC 159 would follow these same rules, although this should probably
be explicitly stated in the RFC.

-Nate

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