lkml.org 
[lkml]   [2019]   [Nov]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    Date
    SubjectRe: [GIT pull] core/urgent for v5.4-rc7
    On Sun, Nov 10, 2019 at 2:01 PM Joe Perches <joe@perches.com> wrote:
    >
    > trivia:
    >
    > This idiom '!!(logical test)' is odd and redundant.
    > Logical test result is already 0 or 1, no !! is unnecessary.

    You are of course correct.

    I have to say, I personally have always disliked the idiomatic C "!!"
    pattern. I don't think it reads well, although that's probably "C
    cultural" - once you are used to the pattern, you don't think of it as
    anything else.

    Personally, I prefer "x != 0" over "!!x" since it reads much better to
    a human, and is equally legible whether you're used to the !! pattern
    or not.

    C is not perl, the Obfuscated C contest not-withstanding.

    And since modern C has bool, if you really want to use a cast-to-bool
    instead of "x != 0", I think doing exactly that is preferable to "!!".

    So I think both "x != 0" and "(bool)x" are preferable to "!!x", and
    would also have made it obvious how odd and redundant the test was in
    this case.

    But "!!x" is shorter, of course. And it you learnt C with that pattern
    it looks obvious.

    Linus

    \
     
     \ /
      Last update: 2019-11-10 23:36    [W:2.438 / U:1.448 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site