On Wed, Jun 04, 2008 at 11:00:41PM +0200, Branko Čibej wrote:
> Stefan Sperling wrote:
> > On Wed, Jun 04, 2008 at 08:30:48PM +0100, Philip Martin wrote:
> >> To my eye strcmp() == 0 is as ugly as the construct 5 == x; I find
> >> !strcmp() is as natural as !ptr. entries.c used both strcmp styles
> >> and ! form was dominant so at least one other developer must agree
> >> with me. I realise styles change; years ago when I started writing C
> >> the people I worked with would only ever have written strcmp() == 0 if
> >> it was mixed with strcmp() > 0 or strcmp() < 0.
> > In my mind, ! is a boolean operator, and strcmp() does not return
> > a boolean value:
> > RETURN VALUES
> > The strcmp() and strncmp() return an integer greater than, equal to, or
> > less than 0, according as the string s1 is greater than, equal to, or
> > less than the string s2.
> > For pointers, ! makes sense -- the pointer is either valid or it isn't.
> I can think of several billion pointer values that are invalid and yet
> not NULL.
Yes, but most code just wants to know whether a pointer is NULL
or not before dereferencing or doing arithmetic on it.
> And it strikes my that far too much effort is being spent on stylistic
> nits lately. Yes, consistent style is important, but working code is
> more important.
Could it be that you perceive recent questions and remarks about coding
style I posted to the list as the stylistic nits you mention?
By doing this, I'm simply trying to figure out what the conventions are,
and try to adhere to them. Not every little thing is documented in HACKING.
Overall, I find Subversion's code remarkably consistent and readable.
The only inconsistencies I know of so far are uses of strcmp, putting
a space after ! or not, and putting a newline after function return
types or not.
FWIW, I don't mind dealing with such inconsistencies at all, as long as
I know that people have agreed on being inconsistent. Which is the case
for all the above, except that strcmp() seems to be reopened for debate.
Before this thread I wasn't consciously aware that there was a (recently
introduced) preferred convention for strcmp().
> To misquote some US president, if you can't read the code, get out of the
I was trying to provide a mnemonic for people who find strcmp() == 0
unnatural. Where was I saying "eww I can't read this"?
> >> Writing strcmp() == 0
> >> on it's own it would probably have attracted comments referring to
> >> Pascal, or Modula2, and the subsequent debate would inevitably include
> >> "of course a real programmer would use FORTRAN".
> > Heh. When I started programming, many people had already forgotten
> > that these languages ever existed :)
> Yes, I assumed as much.
You hardly ever say things I cannot agree with, but at the same time
you're grumpier than gcc -Wall -pedantic.
Received on 2008-06-05 01:36:53 CEST
- application/pgp-signature attachment: stored