Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Open Source Chess Programs

Author: William Hoggarth

Date: 16:52:28 06/07/05

Go up one level in this thread


On June 07, 2005 at 19:28:13, Dann Corbit wrote:
>>I don't see how comments increase code complexity at all.
>
>And yet they do.  An added comment is the same as an added line of code.
>And {for instance} if you see this:
>
>// decrement the index:
>index++;
>
>which is supposed to be correct?
>
>So if you add comments, they absolutely, positively must stay in sync with the
>code or they introduce a serious defect.

Keeping comments in step with the code really isn't very hard at all. Its a very
small price to pay for a big gain in readability.

>TSCP became popular because it is open source and clearly written (assuming a
>zillion globals won't cause you problems).

Yes, it's clearly written because it has comments.

>Probably you mean:
>
>Side  ^= 1;
>
>>switch_sides(Side)
>
>or they are not equivalent, unless they are both the object of an assignment.

Sorry, it was a typo on my part.

>>The second is a lot more readable and both will compile to the same code
>>(assuming you've set up the macro right).
>
>Both seem equally clear to me.

Yes they would to an experienced Chess programmer, but that's not the kind of
person I am talking about. That example is quite a simple one too. Things like
(from<<7)|(type<<17) are more cryptic.

>Never use macros for functions.  They are not type safe, and can have evil,
>unexpected side effects that are different from a function call because of the
>sequence point.
>
>Inline functions are the same speed as macros.

True, inline functions are better, and both are preferable to the kind of
cryptic code I've mentioned.


These were my thoughts on what I think would help. I know they would help me and
they tie in with what I have read is good practice. As Tord says people are
having problems reading his code, perhaps you have a better explanation for this
than I?



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.