[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Boolean tests etc. [was: [PATCH]: Fix off-by-one error in xdelta]

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: 2005-02-19 02:33:16 CET

Daniel Berlin wrote:
> On Fri, 18 Feb 2005, Julian Foad wrote:
>> Of course you were intending to start the log message with a summary,
>> and give it some indentation :-)
>
> I'll edit it

Thanks.

>> Please may I beg you not to compare Boolean values with TRUE or FALSE,
>> but just write "if (match)" or in this case "if (! match)".
>
> GCC tends to require the exact opposite in almost all cases, so it's out

(Meaning "The GCC developers require ... in their source code".)

> of habit. Especially since svn_boolean_type isn't a real boolean type,

(I agree it isn't. You have to move to C'99 to get a real Boolean type in C.)

> you'd want to know if it accidently took on some non-TRUE/non-FALSE

Huh? Unless you write "if (b == TRUE) ...; else if (b == FALSE) ...; else
error();" how would you know if it accidentally took on some non-TRUE/non-FALSE
  value? Also, values other than 1 are commonly generated to mean TRUE by
various functions (typically those that use bitwise AND, e.g. isdigit), because
"non-zero means true" is a fundamental part of the C language. (For this
reason, comparison with FALSE is safe, whereas comparison with TRUE is dangerous.)

> value (I was raised in the "if you simulate boolean with int or char,
> make sure you compare it against true or false" school :P)

I can't blame you for doing what you've been taught, but I'd like to read about
the rationale for that school of thought, as I'd like to understand it.

> However, i'll remember not to do it in the future. It certainly seems
> odd to me.

Thanks.

>> Oh, I see you've just committed it. (That wasn't even one hour, was
>> it? :-)
>
> I sent this email roughly 4 hours beforehand. It's possible my mail
> didn't make it to my mail server until i reconnected, but it didn't
> appear to be sitting in my outbox

Understand that it really isn't a problem; I'm only continuing this discussion
for amusement and interest ... so, this is from your original post:

> Received: (qmail 17101 invoked from network); 18 Feb 2005 22:50:39 -0000
> From: Daniel Berlin <dberlin@dberlin.org>
> To: dev@subversion.tigris.org
> Content-Type: multipart/mixed; boundary="=-zkvFo21q4ftSaNEJ9a5n"
> Date: Fri, 18 Feb 2005 17:49:59 -0500

... showing that your mail client dated the message just a few minutes before
it reached the list. It must have been sitting in some sort of local "out box"
until you reconnected.

- Julian

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Feb 19 02:34:40 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.