Let's try this again now that I've resubscribed with the correct email
address:

> On Wednesday 09 December 2009 07:52:22 pm Peter Kasting wrote:
> > You haven't really said why.  The closest you got was the vague "It
> is also
> > true that the current style guidelines if
> > practiced pedantically in every case can lead to potential bugs."
> Bugs
> > like what?  Perhaps if there are some, we should change the
> appropriate
> > guide, instead of leaving the choice up to a reviewer, who, if the
> rule
> > really _can_ be problematic, might erroneously enforce it.
> 
> Off the top of my head as a reviewer I'd accept:
> 
>       if (color.red() == 255 && color.green() == 0 && color.blue() ==
> 255) // pink!
> 
> over
> 
>       if (color.red() == 255 && !color.green() && color.blue() == 255)
> // pink!
> 
> most days of the week...  Consistency and all that.

I was trying to come up with an example for exactly that situation last
night.

The actual potential bug in this comes when "if (!color.green())" comes
on its own - it looks to a casual glance like green() returns a bool
saying whether this color is green or not. Obviously nobody would make
that mistake, but in a more obscure API (possibly to a 3rd-party
component, so we can't sanitize it) the distinction could trip people
up.

This is a corner case and one that's unlikely to come up, which is why
it's not worth putting into the coding standard, but it's exactly the
sort of thing where a submitter should be able to say, "I've broken the
style guide deliberately here because I think this expression is much
clearer with an explicit test against 0".

Joe

---------------------------------------------------------------------
This transmission (including any attachments) may contain confidential 
information, privileged material (including material protected by the 
solicitor-client or other applicable privileges), or constitute non-public 
information. Any use of this information by anyone other than the intended 
recipient is prohibited. If you have received this transmission in error, 
please immediately reply to the sender and delete this information from your 
system. Use, dissemination, distribution, or reproduction of this transmission 
by unintended recipients is not authorized and may be unlawful.
_______________________________________________
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev

Reply via email to