Re: OnPaint & BMP question

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



No, what I mean is if you have a bool or BOOL, you just USE it!

Example
BOOL b;

if(b)

that's it. A boolean value is either true or false. COMPARING to true or false is silly
and redundant. It is exactly the same as my example about compare. Writing
if(b == false)
is as silly as writing
if((a < 0) == false)
if you want to check for b being false, write
if(!b)
the same as you would properly write
if(a >= 0)
I find the habit of comparing booleans to false or true to be one that any number of
programmers have picked up, for reasons that can make no sense. It is a particularly
execrable style. Anyone who teaches it is not in touch with reality, or has so badly
misunderstood the concept of "boolean" that they should stop teaching (if they can't get a
concept this simple right, what else are they doing wrong?)--and I have been told by one
correspondent that he had been "taught that this is the right way". It isn't.
joe

On Mon, 24 Oct 2005 16:50:43 GMT, "Jona Vark" <noemail@xxxxxxx> wrote:

>
>"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
>news:lqaol1dv7uvktj61uho6fj4hti6fvtiioa@xxxxxxxxxx
>
>>>You should also avoid ever writing ==false or ==true; it is as silly as
>writing
>>>if( a > b == true)
>boolean values stand for themselves, and should never be compared to true or
>false (and it
>is usually a fatal mistake to compare a BOOL == TRUE).
>
>Are you saying to compare them to 1 & 0 instead? false/true have always
>worked ok.. don't find that silly actually.
>
>
>>>means you can write "." instead of the uglier "->" everywhere in the body.
>
>I'm actually laughing now, joe.
>
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: [re-post] why no output
    ... Surely you want to loop while get_script is returning ... But if you're bothering to declare it as returning bool rather than ... you should be comparing its return value with true or false, ... you should never declare a boolean value to true or false. ...
    (comp.lang.c)
  • Re: Coding Horrors, Cargo Cult Programming, and other Ghoulish Things
    ... ByteBool, LongBool, WordBool, Bool are all identical to Boolean except: ... The only problem I could see would be if you converted a bool with a val ... I can't remember the exact scenario now, and it may have involved a bytebool ... comparing to true does not always work. ...
    (borland.public.delphi.non-technical)
  • Re: Difference between BOOL and bool and boolean
    ... > Can u pls suggest the difference between bool, BOOL and boolean. ... bool is a built-in type in C++ that occupies a single byte. ... you're writing in C# or Java. ...
    (microsoft.public.vc.language)
  • [PATCH] drivers/block/DAC960: Converted boolean to bool
    ... Converts 'boolean' to 'bool' and removes the 'boolean' typedef. ... unsigned char CommandOpcode2, ... typedef struct DAC960_SCSI_RequestSense ...
    (Linux-Kernel)
  • [PATCH] drivers/video/sis: Convert to generic boolean
    ... BOOLEAN -> bool ... Have followed all function/variable paths who been converted to 'bool' ... SiS_GetModeID(int VGAEngine, unsigned int VBFlags, int HDisplay, int VDisplay, ...
    (Linux-Kernel)