httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roy T. Fielding" <field...@ebuilt.com>
Subject Re: [PATCH] some fixes for ap_http_filter
Date Fri, 05 Oct 2001 06:10:15 GMT
On Thu, Oct 04, 2001 at 07:50:33PM -0700, Justin Erenkrantz wrote:
> On Thu, Oct 04, 2001 at 07:13:16PM -0700, Aaron Bannert wrote:
> > Huh? That's a bit of a stretch. If this is going to turn into a style
> > war, let it be spoken from the Apache Style Guide:
> > 
> > "Opening braces are given on the same lines as statements, or on the
> > following line at the start of a function definition."
> 
> I'd like to point out the other bazillion places where this happens.
> I don't care.  I'm just pointing out that if you want to change
> the style, change style without changing anything else.  That
> seems to be the operative rule that most people work under.
> 
> Furthermore, I won't commit any patches that change the braces, so 
> there!  =)  When you finally get commit access or find someone who 
> agrees to enforce this point (I'm sure Ryan will do so), I don't 
> care.  It isn't a big enough of a deal.  *I DON'T CARE*  =)  
> Whatever...
> 
> [ Please realize that I'm writing this laughing... ]

You know, this type of bantering gets really annoying when it is on a mailing
list, even though it is pretty amusing to see you two discuss it over dinner.
Let's restrict the discussion to things you actually care about.

> > > No, I think that if you are not familiar that the C construct 
> > > (ctx->remaining) is equivalent to (ctx->remaining != 0) than I
> > > don't really have any sympathy for you.  IMHO, we're not here to 
> > > teach people C.  =)
> > 
> > Bzzzt, wrong! Those are not semantically equivalent statments. The !
> > operator treats the operand as a boolean, the == operator treats the
> > operands as the same type. Let me do some english translations:
> > 
> > if (!ctx->remaining) {
> > 
> >  "If ctx->remaining is not true..."
> > 
> > 
> > if (ctx->remaining <= 0) {
> > 
> >  "If ctx->remaining is less than or equal to zero..."
> > 
> > There is a huge semantic difference there, and it plays directly into the
> > readability of the code.
> 
> Yoohoo, look again - that's not what I said.  =)  I'm not disagreeing 
> that <= 0 is different (of course it is).  I'm saying that != 0 is 
> identical to not having the explicit comparison (and I bet there is
> someone out there that will prove me wrong).  Also, there is no 
> boolean type in C.  =)  You *are* thinking of Java - I knew it...

Aaron's change is correct -- it is one of the principles of defensive
programming that all logical branches of a program should be correctly
followed even if the input is unexpected.  Let's say a cosmic ray happens
to pass through the memory chip and sets that value to be negative.
Which branch of the tree is more likely to be a safe path?  An assert
is never a safe path in production code.

Likewise, defensive programming calls for curly-braces around blocks
of conditional code.  Don't argue about things that aren't worth the
effort of *me* having to read the argument.

....Roy


Mime
View raw message