Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: what classes all the serious C++ chess programs have?

Author: Gerd Isenberg

Date: 06:42:21 08/10/04

Go up one level in this thread


On August 10, 2004 at 08:28:53, Tord Romstad wrote:

>On August 10, 2004 at 05:37:10, Gerd Isenberg wrote:
>
>>Generic inline wrapper classes for pieces, moves, hashentries etc. are IMHO nice
>>to hide implementation and to write "ugly" code once, without any performance
>>penalty, some examples which same assembly output:
>>
>>   if (piece & 0x80) ...
>>   if (piece & SLIDING_BIT) ...
>>   if (isSlding(piece) ) ...
>>   if (piece.isSliding()) ...
>>or
>>   if (hashentry.flags & 0x01) ...
>>   if (hashentry.flags & LOWER_BOUND) ...
>>   if (hashentry.isLowerBound() ) ...
>>
>>I prefere the latter.
>
>I understand why you want to avoid the '&' variants, but why is
>piece.isSliding() better than isSliding(piece), and hashentry.isLowerBound()
>better than isLowerBound(hashentry)?
>
>Tord

May be a matter of taste or addiction - C-Style versus C++ style.

In isSliding(piece) the function may be in some global namespace and if "piece"
and "square" are both enum types the compiler is not able to distinguish between
isSliding(piece) and isSliding(square).

If you restrict the function scope to classes, piece.isSliding() is fine while
square.isSliding() produces an error.

Gerd



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.