Author: David Rasmussen
Date: 09:15:38 01/22/03
Go up one level in this thread
On January 22, 2003 at 09:26:22, José Carlos wrote:
>
> No need for "ugly" defines in C; no performance loss:
>
I know that.
>inline TPiece GetBoardSquare(int sq)
>{
> assert(sq >= 0 && sq < 64);
> return(Board[sq]);
>}
>inline SetBoardSquare(int sq,TPiece piece)
>{
> assert(sq >= 0 && sq < 64);
> assert(piece_is_a_legal_value);
> Board[sq] = piece;
>}
>
Instead your code is either filled with asserts() or you have centralized access
functions with special names instead of built-in operatiors. What you do above
is probably what I would do, if I were forced to use C. If.
> Asserts only compile in debug mode. You don't _need_ C++ to write good code.
>
I haven't said that. But I think that it's easier, in general and in this case.
I am not making the case that C++ is the only way, but too many C programmers
(in this club and in general) has all sorts of imaginary reasons not to use C++,
so I'm just advertising a bit for C++. Especially when there is something that
it's better at.
/David
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.