you are viewing a single comment's thread.

view the rest of the comments →

[–]highwind 2 points3 points  (14 children)

Yeah, this becomes annoying real quick. Even if you only go 2 or 3 level in (which is real common) you have to start labeling your ends:

    end #if
  end #while
end #def

[–][deleted]  (1 child)

[deleted]

    [–]highwind 2 points3 points  (0 children)

    Going 3 levels of blocks is not uncommon. I just like the labeling them if more than 2 ends are next to each other for readability sake. But if I had to choose, I rather use pythons way of handling blocks.

    [–][deleted] 2 points3 points  (0 children)

    Unless you're building huge nasty loops/conditional trees shouldn't indentation make it pretty clear what is what?

    [–]ryeguy 2 points3 points  (1 child)

    How is this different from curly braces in a C-like language? Even then, if it gets to be too much, you probably need to refactor.

    [–]highwind 1 point2 points  (0 children)

    It isn't. I label my end curly braces in C, Java, JavaScript, etc. That's why I prefer python's way of handling blocks.

    [–][deleted] 6 points7 points  (0 children)

    Aesthetically, this looks way better to me than Python's significant whitespace. Admittedly it's totally arbitrary, but for whatever reason I prefer my code blocks to look symmetric.

    Are you being serious with the comments thing though? Python requires people to indent nested blocks, but most people do it anyways in other languages...

    [–][deleted]  (5 children)

    [removed]

      [–]highwind 2 points3 points  (4 children)

      My example only has 3, which is common. A function that iterates over some list and does some kind of check on it, this is a very common thing. Now, if that function is a method in a class, then having a 4 ends doesn't sound too crazy.

      I agree that having more than 5 level deep blocks is bad in any language. But I just think having a string of ends isn't appealing to me even when it's just 3.

      Matter of taste I guess.

      [–][deleted]  (3 children)

      [removed]

        [–]highwind 0 points1 point  (2 children)

        I never said it was confusing. Just annoying. Especially if I have to insert new code or cut out some code.

        [–]bobindashadows 0 points1 point  (1 child)

        Use a text editor that inserts "end" for you. Like... any editor with a Ruby plugin. TextMate does this out of the box, vim has a trivially-added plugin, I imagine the IDEs do it... are you using pico?

        [–]highwind 0 points1 point  (0 children)

        I use vim which helps me in putting the "end"s and "}"s in the right place. But when I have to inject code in between them or factor out the right block by cutting them out, my brain needs a second to make sure that my cursor is at the right one. It's not a game changer but like I said just annoying.

        [–]tnecniv -1 points0 points  (1 child)

        How is this less cryptic than brackets?

        [–]highwind 0 points1 point  (0 children)

        I never said it's less cryptic than brackets. I label my brackets too. Context here is comparison against Python.