Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: A free compiler you might not have heard about ...

Author: Vincent Diepeveen

Date: 03:26:07 04/20/02

Go up one level in this thread


On April 19, 2002 at 17:02:01, Roy Eassa wrote:

>On April 19, 2002 at 15:11:32, Miguel A. Ballicora wrote:
>
>>On April 19, 2002 at 14:00:15, Dann Corbit wrote:
>>
>>>On April 19, 2002 at 13:44:24, Miguel A. Ballicora wrote:
>>>
>>>>On April 19, 2002 at 13:19:12, Dann Corbit wrote:
>>>>
>>>>>On April 19, 2002 at 05:38:16, Gian-Carlo Pascutto wrote:
>>>>>
>>>>>>On April 19, 2002 at 03:53:35, Dann Corbit wrote:
>>>>>>>    if (pawn_rank[LIGHT][f] == 6);      /* pawn hasn't moved */
>>>>>>>                                ^
>>>>>>>eval.c(335) : Warning 7: possible extraneous ';'
>>>>>>>    if (pawn_rank[DARK][f] == 1);
>>>>>>>                               ^
>>>>>>>eval.c(382) : Warning 7: possible extraneous ';'
>>>>>>
>>>>>>Is TSCP buggy?
>>>>>>
>>>>>>I think this is a very valuable warning, too bad neither
>>>>>>MSVC, Intel C or gcc don't have it.
>>>>>
>>>>>Nothing wrong with TSCP.  If you look at the code in place, it is obvious.
>>>>>I tend to do this:
>>>>>    if (pawn_rank[DARK][f] == 1) {;} /* I meant to do that. */
>>>>>For those bizarre cases where you want the if to do nothing.
>>>>
>>>>Ok, now I understand the idea. It is in a place where there are a bunch of "if"
>>>>most of them do something and few do nothing but they are kept for
>>>>sake of "completeness" (it could be edited later to introduce "something").
>>>>Almost like a comment right?
>>>
>>>Sometimes, the most frequent branch is where you want to do nothing.  In such
>>>cases, it can be better to do it like Tom did, up above.  Usually, it should get
>>>a comment.  In this case, when you look at the code, it is clear that there is
>>>no problem:
>>>
>>>nt             eval_dkp(int f)
>>>
>>>   int             r = 0;
>>>
>>>   if (pawn_rank[DARK][f] == 1);
>>>   else if (pawn_rank[DARK][f] == 2)
>>>       r -= 10;
>>>   else if (pawn_rank[DARK][f] != 7)
>>>       r -= 20;
>>>   else
>>>       r -= 25;
>>>
>>>   if (pawn_rank[LIGHT][f] == 0)
>>>       r -= 15;
>>>   else if (pawn_rank[LIGHT][f] == 2)
>>>       r -= 10;
>>>   else if (pawn_rank[LIGHT][f] == 3)
>>>       r -= 5;
>>>
>>>   return r;
>>>}
>>
>>It took me like 3 messages to get 100%. Ok, not only I understand now...
>>but I can say that I do that too! Lack of imagination from my part to guess that
>>an "else" could be after. In my case sometimes I just waste a line to make it
>>visually more clear for me with parenthesis. Just a matter of taste
>>(and I silence some compiler warnings)
>>
>>if (bool_var) {
>>     ;
>>} else
>>    c = 2;
>>
>
>
>I think I've done it like this:
>
>if (bool_var)
>   {}
>else
>   c=2;
>
>
>Is it bad to omit the semicolon?

most here are too optimistic. look at the compiler assembly
output first before knowing whether it is faster.



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.