From: | Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl> |
---|---|
To: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Stark <gsstark(at)mit(dot)edu>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: sparse (static analyzer) report |
Date: | 2005-01-15 13:41:37 |
Message-ID: | 20050115134137.GA25902@dcc.uchile.cl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sat, Jan 15, 2005 at 08:31:42AM -0500, Andrew Dunstan wrote:
> Tom Lane wrote:
> >Something that I don't have a real strong feeling about is
> > if (ptr != NULL)
> >versus
> > if (ptr)
> >I've been known to write both. Can anyone mount a good readability
> >argument for one over the other?
I assume people don't like the PointerIsValid() macro defined in c.h?
Just for consistency we could use that everywhere or get rid of it ...
but then, maybe it is used by external code so we shouldn't do the
latter.
> >How about the inverse case,
> > if (ptr == NULL)
> >versus
> > if (!ptr)
> >Applying a boolean ! to a pointer seems a bit shaky to me, though
> >it's certainly a common locution.
>
> If we allow "if (ptr)" then allowing the inverse to be "if (! ptr)"
> seems logical enough. As you say, it's a very common idiom, and allowing
> one without the other would be rather non-orthogonal.
I'd rather have legibility over orthogonality on this issue. I prefer
ptr == NULL myself, though not too strongly.
--
Alvaro Herrera (<alvherre[(at)]dcc(dot)uchile(dot)cl>)
"No necesitamos banderas
No reconocemos fronteras" (Jorge Gonzlez)
From | Date | Subject | |
---|---|---|---|
Next Message | Devrim GUNDUZ | 2005-01-15 13:51:31 | Latest Turkish translation updates |
Previous Message | Andrew Dunstan | 2005-01-15 13:31:42 | Re: sparse (static analyzer) report |