Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Any reason to use C?

Author: Sune Fischer

Date: 12:06:33 07/29/03

Go up one level in this thread


On July 29, 2003 at 14:31:43, Dieter Buerssner wrote:

>On July 29, 2003 at 09:38:30, Sune Fischer wrote:
>
>>Absolutely, operator overloading rocks.
>>Just try working with vectors and matrices in C :o
>
>In many cases, overloading might be nice for matrix/vector computations. In my
>practical experience, however, I would not have found too much good use for it.
>I did a lot of quantum mechanical simultions. Often matices have a special
>symmetry, that the algorithms want to take advantage of. With the classical way
>(function calls instead of operators) I have visual feedback of what happens
>behind the scene (say a function start may start like sparse_antisymmetric_...).
>To get a real comlete system of overloaded operators seems almost impossible.
>Then, say you want to call Eigenvalues. There are different algorithms, and
>specific situations will call for a specific algorithm.

Yes it is not ideal for every situation, but it is one of those many extra tools
you have at your disposal in C++.
Sometimes the good ol' C method is just better design.

>I found overloading really useful for checking numerical stability. Instead of
>double, I use something like my_floating_point_type. Then I can easily plug in a
>100 digit precision floating point class. Something like this would be very hard
>and error prone work, without operator overloading.

I used it once heavily to translate a MHD Fortran program, with overloading
equations could be translated directly with just minor syntax changes.

>For chess engines: I use C in my engine, but there is one point, where I miss
>C++: formating of the output. With C++, changing 32 bit counters (for nodes,
>etc.) to 64 bit counters, could be rather easy. With C-printf-style formating,
>it is a lot of work (change all format strings).

I actually use it, but only in debug mode where I can compare boards and trees.
I guess the assignment operator has been overloaded by default, I refering also
to C with structures. I do think it is a really good feature when used at the
right places.

I have thought about turning my MOVE typedif into a class, for that I will
definitely be needing a few overloads.

I have also thought about using a class for the score type, I might eventually
decide to pass around more than just a scalar value. Again it couldn't be done
without overloading the comparisons operators.

But, I'm just not sure if these operators will cause a function call, and
thereby a significant slowdown.

-S.

>Regards,
>Dieter



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.