[webkit-dev] !!Tests for equality comparison
Keith Miller
keith_miller at apple.com
Thu Apr 27 16:50:45 PDT 2017
I agree that using ! does not make the code more readable. I almost always find ! subtly harder to read.
Keith
> On Apr 27, 2017, at 4:36 PM, Caio Lima <ticaiolima at gmail.com> wrote:
>
> O also think it's a good notation. It helps a lot the code reading IMO.
>
> Caio.
> Em qui, 27 de abr de 2017 às 20:33, Chris Dumez <cdumez at apple.com <mailto:cdumez at apple.com>> escreveu:
> I also do not like this rule when it comes to integers.
>
> I personally think JF’s proposal to allow == 0 sounds nice. I don’t think JF was suggesting rewriting existing code (which would indeed cause a lot of churn).
>
> --
> Chris Dumez
>
>
>
>
>
>> On Apr 27, 2017, at 4:30 PM, Geoffrey Garen <ggaren at apple.com <mailto:ggaren at apple.com>> wrote:
>>
>
>> I’ve never really liked this style rule, and I’ve always felt like it snuck into the style document without much discussion.
>>
>> Even so, I usually tolerate it.
>>
>> Geoff
>>
>>> On Apr 27, 2017, at 4:06 PM, JF Bastien <jfbastien at apple.com <mailto:jfbastien at apple.com>> wrote:
>>>
>>> Hello C++ fans!
>>>
>>> The C++ style check currently say:
>>> Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons
>>>
>>> I totally agree for booleans and pointers… but not for integers. I know it’s pretty much the same thing, but I it takes me slightly longer to process code like this:
>>>
>>> int numTestsForEqualityComparison = 0:
>>> // Count ‘em!
>>> // …
>>> if (!numTestsForEqualityComparison)
>>> printf(“Good job!”);
>>>
>>> I read it as “if not number of tests for equality comparison”. That's weird. It takes me every slightly longer to think about, and I’ve gotten it wrong a bunch of times already. I’m not trying to check for “notness", I’m trying to say “if there were zero tests for equality comparison”, a.k.a.:
>>>
>>> if (numTestsForEqualityComparison == 0)
>>> printf(“Good job!”);
>>>
>>> So how about the C++ style let me just say that? I’m not suggesting we advise using that style for integers everywhere, I’m just saying it should be acceptable to check zero/non-zero using equality comparison.
>>>
>>>
>>> !!Thanks (i.e. many thanks),
>>>
>>> JF
>>>
>>> p.s.: With you I am, fans of Yoda comparison, but for another day this will be.
>>> _______________________________________________
>>> webkit-dev mailing list
>>> webkit-dev at lists.webkit.org <mailto:webkit-dev at lists.webkit.org>
>>> https://lists.webkit.org/mailman/listinfo/webkit-dev <https://lists.webkit.org/mailman/listinfo/webkit-dev>
>>
>> _______________________________________________
>> webkit-dev mailing list
>> webkit-dev at lists.webkit.org <mailto:webkit-dev at lists.webkit.org>
>> https://lists.webkit.org/mailman/listinfo/webkit-dev <https://lists.webkit.org/mailman/listinfo/webkit-dev>
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org <mailto:webkit-dev at lists.webkit.org>
> https://lists.webkit.org/mailman/listinfo/webkit-dev <https://lists.webkit.org/mailman/listinfo/webkit-dev>
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20170427/a815644f/attachment.html>
More information about the webkit-dev
mailing list