• GNU/Dhruv@lemmy.ml
    link
    fedilink
    arrow-up
    8
    ·
    1 年前

    Is this some kind of python meme I’m too C++ to understand?

    Now, I’m completely willing to start a war about { going on the next line.

      • GNU/Dhruv@lemmy.ml
        link
        fedilink
        arrow-up
        7
        ·
        1 年前

        It goes on the next line, so you can have open and close brackets at the same indent depth for easy visual matching.

    • TheInsane42@lemmy.ml
      link
      fedilink
      arrow-up
      3
      ·
      edit-2
      1 年前

      Totally agree, all my { end up on the next line, 1st spot when starting a function, last character of the keyword when starting an if/for/… section. I even put the closing one on the same line when it’s single line, else either at the end of the closing line (when changing really old code) or same indent.

      So indenting varies a lot, which makes most ‘new’ programmers go mental.

      while (my code)
          { I'll do it my way }
      
      if (! liked)
       { toughen-up }
      else
       { get used to it
         multi-line can go both ways...
       }
      

      That is, unless the font used messes it up. ;)

        • TheInsane42@lemmy.ml
          link
          fedilink
          arrow-up
          1
          ·
          1 年前

          To be honest, I think the forced ‘fixed’ indent in python is horrible, not being able to identify the different block function just by the indent, not being able to use % in vi to find the correct end,…

          Much be an age thing, I learned to program in the 80s.

      • salimundo@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        1 年前

        Why isn’t the else curly lined up with the end of the else word? I’d your gonna go crazy might as well go all the way I guess 😜

        • TheInsane42@lemmy.ml
          link
          fedilink
          arrow-up
          1
          ·
          1 年前

          The { of the else is just the 2nd, optional, part of the if statement, so I was learned to align it with the opening keyword. I do the same with the then keyword, when the language requires a then, then it’s aligned with the i if if an the { with the f of if.

          In the old days, when memory was expensive (in the day of 4k computers), even an extra cr/lf was worth preventing. Hence C has no then, C layout is usually { … } for one liners… or even without the { },… I learned to program in the IT dark ages. ;)

    • Saigonauticon@voltage.vn
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 年前

      Wonder what the x-axis is? Survey year? Years of experience? Caffeine intake?

      Anyway, I can hardly join a holy war – I code in assembly most comfortably, which I’m pretty sure is heresy these days.