Re: Can overloaded '+' return an array? If so, how?
- From: "PeterSShenkin" <shenkin@xxxxxxxxx>
- Date: 30 Aug 2006 13:19:54 -0700
xhoster@xxxxxxxxx wrote:
Yep. And, in fact, I would usually expect an overloaded addition
operator to turn something of the same class as (at least one of) it's
operands, so I suggest that not only should it return a ref, but a ref
that is blessed into ClassAct.
That expectation is not fulfilled either in mathematics or in Perl
native types.
In Perl, an int divided by an int is not necessarily an int.
In mathematics, the dot product of two vectors is a scalar. The outer
product is a matrix.
Thus, if the inability of an overloaded '+' to always return a scalar
was a conscious decision, I believe it was the wrong one. What if you
want to add two arrays?
Be all this as it may, my thanks to those who responded. I guessed
this is the way it would turn out, because I couldn't see anything I
was doing wrong. I'll have to add it to my list of Perl sins (along
with the inability to handle IEEE exceptional values in a standard
way).
Cheers,
-P.
.
- Follow-Ups:
- Re: Can overloaded '+' return an array? If so, how?
- From: xhoster
- Re: Can overloaded '+' return an array? If so, how?
- From: PeterSShenkin
- Re: Can overloaded '+' return an array? If so, how?
- References:
- Can overloaded '+' return an array? If so, how?
- From: PeterSShenkin
- Re: Can overloaded '+' return an array? If so, how?
- From: xhoster
- Can overloaded '+' return an array? If so, how?
- Prev by Date: Re: Can overloaded '+' return an array? If so, how?
- Next by Date: Re: Can overloaded '+' return an array? If so, how?
- Previous by thread: Re: Can overloaded '+' return an array? If so, how?
- Next by thread: Re: Can overloaded '+' return an array? If so, how?
- Index(es):
Relevant Pages
|