Stefan Sperling wrote on Wed, 4 Jun 2008 at 22:06 +0200:
> 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:
>
Yeah, but the difference between
strcmp("foo", "bar") == 0
and
strcmp("foo", "bar") != 0
is exactly one character. With
! strcmp("foo", "bar")
you can tell immediately that it tests for equality.
</bikeshed>
> > 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 :)
>
I wonder what languages they teach in high schools these days...
> Stefan
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-06-04 22:41:11 CEST