[MPlayer-dev-eng] int vs. bool

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sat Dec 1 17:16:15 CET 2012


On Sat, Dec 01, 2012 at 12:27:13PM +0100, Ingo Brückl wrote:
> Reimar Döffinger wrote on Sat, 1 Dec 2012 08:10:56 +0100:
> 
> > On 1 Dec 2012, at 00:15, Ingo Brückl <ib at wupperonline.de> wrote:
> >> Reimar Döffinger wrote on Fri, 30 Nov 2012 19:42:31 +0100:
> >>
> >> I think the code will become more self-explanatory than directly using 0
> >> and 1 with int variables.
> 
> > Why? Is this maybe something that can be solved by better variable names?
> 
> No, it's just because something like
> 
>   stop = true;
> 
> or
> 
>   guiInfo.PlaylistNext = false;
> 
> is a lot easier to understand than

Well, we have AF_TRUE and VO_TRUE for that kind of thing.
The problem I see in the code though is that there is no way
to force people to use it, resulting in an unholy mixture
with a few bugs caused by it on top.

> but if you don't like it I will not insist.

Well, I guess for me the one reads as well as the other.
And a GUI_TRUE and GUI_FALSE define would avoid most of the issues,
a few more if combined with an enum.
I just have the feeling that it will at best make the code uglier.
Personally I also hate having to change lots and lots of code
when I notice a simple true/false actually isn't enough...
In the end I don't mind much, particularly if it's only the
GUI code, I'm just not convinced there is any approach I'd consider
an overall win.


More information about the MPlayer-dev-eng mailing list