Re: What is the advantage of "NULL == pMyPointer" instead of "pMyPointer == NULL"?

From: Rob Vermeulen (rpvermeulen_at_tiscali-antispam-.nl)
Date: 04/09/04


Date: Fri, 9 Apr 2004 21:26:09 +0200

That was easy :-)
Much easier than the posting about using "++i" instead of "i++". :-)

Although I must say that I too happen to make such mistakes sometimes
(forgetting the second '=').
That is just the problem of knowing too much programming languages (or any
languages whatsoever). The brain sometimes mixes up the synthaxes :-)

I think I'll use the "NULL==..." version alot more now :-)

Anyway, thanks Peter!

"Pete Becker" <petebecker@acm.org> wrote in message
news:4076B2BB.9E8F488B@acm.org...
> Rob Vermeulen wrote:
> >
> > In several SDK examples of MS I notice the following.
> > To compare a pointer with NULL they do: "NULL == pMyPointer"
> > Why not just the other way around, like every "C++ for dummies" book
> > describes? :-)
> >
>
> Some people worry that they might leave out the second '=' sign and that
> their testing isn't adequate to find such a mistake. Writing the test
> backwards turns this mistake into an error.
>
> --
>
> Pete Becker
> Dinkumware, Ltd. (http://www.dinkumware.com)



Relevant Pages

  • debugging
    ... Several times recently I've made the same mistake: ... forgetting to include the optional argument when recursing. ... which makes about as much sense as building a prison out of meringue. ...
    (comp.lang.lisp)
  • Re: AirCon in off positions
    ... myusdickus is merely adequate for the task at hand..... ... must leave some blood for thought process.... ... Giving up the right to arms is a mistake a free people get to make only once. ...
    (rec.autos.makers.ford.explorer)
  • Re: Shots of my latest bodged aerial job :-)
    ... Bill Wright wrote: ... of forgetting the obvious (well it's obvious after you make the mistake ... To e-mail, change noise into sound. ...
    (uk.tech.digital-tv)
  • Re: kid stuff
    ... in measure six when he plays an E natural ... Is that a tab mistake, or him forgetting ...
    (rec.music.makers.guitar.jazz)
  • Re: Automatic banning based on MB usage
    ... > My mistake... ... Thanks for the correction. ... > forgetting that. ... It is the shadow copy function that was ...
    (microsoft.public.cert.exam.mcse)