Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Any reason to use C?

Author: Sune Fischer

Date: 05:44:40 07/30/03

Go up one level in this thread


On July 30, 2003 at 08:03:06, Omid David Tabibi wrote:

>On July 29, 2003 at 15:17:51, Dann Corbit wrote:
>
>>On July 29, 2003 at 14:18:55, Sune Fischer wrote:
>>>On July 29, 2003 at 13:39:48, Dann Corbit wrote:
>>>>On July 29, 2003 at 09:38:30, Sune Fischer wrote:
>>[snip]
>>>>>Absolutely, operator overloading rocks.
>>>>>Just try working with vectors and matrices in C :o
>>>>
>>>>That's on the one hand.
>>>>
>>>>On the other hand, there is nothing worse than operator overloading gone bad.
>>>>And I really mean it.
>>>
>>>It's intented to make things simpler, not more complicated.
>>>
>>>But your right of course, the powers of C++ is not for the timid.
>>
>>Shot myself in the foot once.  Like every C++ newbie, I wrote a C++ number class
>>(this was long before the <complex> template came to be).
>>
>>I thought it would be nice to use the ^ operator to represent complex
>>exponentiation.
>>BZZTT!!  Wrong operator precedence.  Thanks for playing.
>>
>>Another worse gotcha is when people create a very inobvious operator overload.
>>Or even one that is counter intuitive.
>>
>>I could write a class (for instance) where a comma represents "format the disk"
>>and a minus sign means concatenate two strings together.
>
>or a shift left represents output... ;)

:)

This is probably the abstraction that is hard for some to get used to, that the
operator is defined only in relation to the objects it works upon.

This is actually a very general concept in math, adding two numbers doesn't make
sense if you don't know what field, group or vector space you are dealing with.

I think it is quite elegant, once you're into that line of thought.
On the other hand I can see why it's very confusing if you're used to it meaning
something particular.

-S.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.