[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnugo-devel] Re: use of LOSE in reading.c

From: Teun Burgers
Subject: [gnugo-devel] Re: use of LOSE in reading.c
Date: Fri, 20 Sep 2002 10:02:56 +0200

Dan wrote:

> I agree with Gunnar. We often use the syntax if (!attack( ...)) {
> both in the reading code and in the autohelper macros which
> are compiled into C code. We don't want to rewrite all that
> so it will be hard to make such a change consistently. And
> I don't see any good reason for it.

My reason was that as a next stage I envisaged to introduce
a new typedef (instead of #defines) for attack codes:

typedef enum {LOSE=0, KO_B, KO_A, WIN} attack_code

(LOSS and GAIN should be there too)
and then use attack_code acode instead of int acode.

This would allow compile time checking of using valid values
for attack codes (according to Kernighan and Ritchie 2nd ed.).
See info gcc and look for enum. There are several options
related to enums for extra checking.

This as an extra safeguard (at no cost) against coding errors, similar
to the asserts. Since the asserts have exposed so many bugs, I think
enums could be similary useful.


Drs A.R. Burgers        Energy research Centre of the Netherlands
Phone: +31-224-564959   P.O. Box 1
Fax  : +31-224-568214   NL-1755 ZG Petten
email: address@hidden   The Netherlands

reply via email to

[Prev in Thread] Current Thread [Next in Thread]