[phobos] phobos commit, revision 1919

Jonathan M Davis jmdavisprog at gmail.com
Fri Aug 27 13:00:05 PDT 2010


On Friday 27 August 2010 11:42:54 Andrei Alexandrescu wrote:
> I think I mentioned this - the Timer class we use at work has startup
> dictated by true/false. Most of the code I'm reviewing uses:
> 
>      Timer timer;
>      timer.start();
> 
> thus wasting a vertical line (precious) over the simpler but confusing:
> 
>      Timer timer(true);
> 
> Another example from real code:
> 
>      serialize(output, data, true, true);
> 
> The first true means use Base64 encoding. The second means use compression.

Oh, I get what you're saying, and I don't exactly think that you're wrong. I 
just think that in many cases, bool works just fine. You often have to look up 
the function anyway, so the added clarity isn't much, and the added verboseness 
can be irritating. Obviously it can become a problem if you have multiple bools, 
and using enums instead can improve clarity in many cases, so using enums does 
have its advantages. When it comes down to it, I don't really have any problem 
with using an enum, but I don't really have a problem with bool either. 
Honestly, I don't think that it ever would have occurred to me to use anything 
but an enum did you not propose that enums should be used instead in Phobos.

In any case, I've been using the enum model in the date/time code that I've been 
writing, so you won't have to worry about stray bool parameters in there.

- Jonathan M Davis


More information about the phobos mailing list