Re: [Freeciv-Dev] Re: Merged the both tech patches a little bit
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
Freeciv Dev <freeciv-dev@xxxxxxxxxxxx> |
Subject: |
Re: [Freeciv-Dev] Re: Merged the both tech patches a little bit |
From: |
Artur Biesiadowski <abies@xxxxxxxxx> |
Date: |
Mon, 06 Sep 1999 10:10:10 +0200 |
David Pfitzner wrote:
>
> > - return unit_types[id].flags & (1<<flag);
> > + return (unit_types[id].flags & (1<<flag))?TRUE:FALSE;
> >
> > But I actually don't know if it makes problems
> > (e.g. if a caller assumes that the flag is on the correct
> > place)
>
> I think this is what it should be.
>
> Actually I've been meaning to introduce a macro eg, BOOL()
> which converts to 0,1 (or TRUE,FALSE), to prettify some
> things, especially in code I added in tilespec changes.
>
> But we could have a flameware/competition about how BOOL()
> should be defined ;-)
> Eg,
> #define BOOL(x) ((x) ? 1 : 0)
> #define BOOL(x) ((x) ? TRUE : FALSE)
> #define BOOL(x) (!!(x))
> #define BOOL(x) (1-!(x))
And why do not use just
return (unit_types[id].flags & (1<<flag)) != 0;
?
BOOL seems to be a wrapper to do C-ish conversion of anything to bool -
it defeats it's main advantage (less typing) and does not add any type
safety.
Artur
|
|