Re: Can overloaded '+' return an array? If so, how?
- From: xhoster@xxxxxxxxx
- Date: 31 Aug 2006 16:04:11 GMT
"PeterSShenkin" <shenkin@xxxxxxxxx> wrote:
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.
division is not addition.
In mathematics, the dot product of two vectors is a scalar. The outer
product is a matrix.
multiplication is not addition.
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?
Then you take two arrayrefs (or object) and return an arrayref (or object).
Or are you going to say it is also a mistake that overloaded + always takes
its *arguments* in a scalar context, too?
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
.
- References:
- Can overloaded '+' return an array? If so, how?
- From: PeterSShenkin
- Re: Can overloaded '+' return an array? If so, how?
- From: xhoster
- Re: Can overloaded '+' return an array? If so, how?
- From: PeterSShenkin
- Can overloaded '+' return an array? If so, how?
- Prev by Date: Re: (Off topic) Cyberwar question
- Next by Date: Re: FAQ 6.22 How can I match strings with multibyte characters?
- 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
|