This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [bool wrapping] Request for warnings on implicit bool to int conversions


On 28-Mar-2012 15:20, Michael Witten wrote:

However, it seems to me that toggling the value with the idiom:

--b;

is aesthetically preferable to the more elaborate:

b = !b;

Aesthetically, not logically. Neither of these makes the least bit of sense:


   one less than False
   one less than True

A better solution for the aesthetics would have been (it is a bit late now) to implement the missing unary negation operator:

!!b; //T->F, F->T

That operator would save even more program characters for the other int types, where it would be equivalent to:

(i==0 ? 1 : 0);


Regards,


David Mathog
mathog@caltech.edu
Manager, Sequence Analysis Facility, Biology Division, Caltech


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]