Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Advocacy > Re: Operator Ov...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 7 Topic 2407 of 2475
Post > Topic >>

Re: Operator Overloading (Was: In Praise of Strong Typing)

by Daniel Pitts <newsgroup.spamfilter@[EMAIL PROTECTED] > Jun 22, 2008 at 09:43 PM

Bartlomiej Golenko wrote:
> Daniel Pitts <newsgroup.spamfilter@[EMAIL PROTECTED]
> wrote:
>> This is not bad code (albeit C++ code)
>> Vector operator+(const Vector &left, const Vector &right) {
>>      Vector result;
>>      for (int i = 0; i < Vector::size; ++i) {
>>         result[i] = left[i] + right[i];
>>      }
>>      return result;
>> }
>> ...
>> myNewVect = someVect + someOtherVect;
> 
> Its pure evil. Consider this:
> 
> myNewVect = someVect * someOtherVect;
> 
> What kind of product is it ? 
> - inner product ? 
> - tensor product ? 
> - cross product ?
> - carthesian product ?
> 
> The fact that YOU know exactly how did you overload operator* does 
> not necessarily mean everyone else does as well.
> 
> Regards, BG
> 
Did I overload the * operator in this example? No.

"*" make sense for vector * scalar or scalar * vector in the general 
case, but the "*" glyph for vector (X) vector doesn't make well-defined 
sense.

-- 
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
 




 7 Posts in Topic:
In Praise of Strong Typing
Roedy Green <see_websi  2008-06-22 16:53:28 
Re: In Praise of Strong Typing
Daniel Pitts <newsgrou  2008-06-22 11:21:34 
Re: In Praise of Strong Typing
Roedy Green <see_websi  2008-06-22 20:07:33 
Operator Overloading (Was: In Praise of Strong Typing)
Daniel Pitts <newsgrou  2008-06-22 15:52:00 
Re: Operator Overloading (Was: In Praise of Strong Typing)
Bartlomiej Golenko <ba  2008-06-23 02:00:06 
Re: Operator Overloading (Was: In Praise of Strong Typing)
ram@[EMAIL PROTECTED] (S  2008-06-23 02:38:59 
Re: Operator Overloading (Was: In Praise of Strong Typing)
Daniel Pitts <newsgrou  2008-06-22 21:43:35 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 12:52:34 CST 2008.