• ttmrichter@lemmy.ml
    link
    fedilink
    arrow-up
    2
    arrow-down
    2
    ·
    2 years ago
    for (size_t i = 0; i < 100; i++) calculate_something_and_display(i);
    

    How many lines of code does your system show for this?

    for (size_t i = 0; i < 100; i++)
    {
         calculate_something_and_display(i);
    }
    

    How many lines of code does it show for this?

    for (size_t i = 0; 
         i < 100; 
         i++)
    {
         calculate_something_and_display(i);
    }
    

    What about this?

    for (size_t i = 0; i < 100; i++)
         calculate_something_and_display(i);
    

    And this?

    These are all identical in any meaningful way. The compiler’s parser will see them all as exactly the same sequence of tokens with no difference.

    And now you can understand perhaps why cloc’s complexity isn’t entirely “unnecessary”…

    • ysu@lemmy.mlOP
      link
      fedilink
      arrow-up
      4
      ·
      2 years ago

      Actually my program gives the exact same result as cloc for all of those.

      • ttmrichter@lemmy.ml
        link
        fedilink
        arrow-up
        3
        arrow-down
        1
        ·
        2 years ago

        Ah. Then cloc’s output is apparently meaningless too. Pity. I thought it would at least be recognizing statement count. :-/