in reply to Re^3: How has your coding style changed over the years?
in thread How has your coding style changed over the years?
I also believe in indented closing braces (and I don't care Larry disagrees). I feel strongly for indenting them, as that is IMHO the only logical way to do it.
sub foo { my @args = @_; unless (scalar @args) { warn "No args in foo!"; return; } return join ':' => @args; }
This style is called Ratliff- or Banner-style.
Because braces are just syntactic sugar to keep a block together, it should visually also bind to the block, and not to the conditional. As the closing brace - or END in languages like PASCAL - is visually showing me the end of the block, it should obviously have the same indent as the block itself. An advantage is that the alignment of the closing brace with the block emphasizes the fact that the entire block is conceptually (as well as programmatically) a single compound statement.
In other words: I see the braces being part of the block, and as all statements inside a block share the same indentation, in my opinion the brace - being part of the block - should have the same indentation too.
- Indent width is 4, tabs are allowed (when set to 8). I prefer having it being spaces only, but as I cannot see the difference with good editors, I do not really care.
- Opening brace should be on the same line as the conditional
- Block should be indented
- Closing brace should have the same indent as the block
Enjoy, Have FUN! H.Merijn
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: How has your coding style changed over the years?
by Your Mother (Archbishop) on Aug 10, 2022 at 16:56 UTC | |
Re^5: How has your coding style changed over the years?
by LanX (Saint) on Aug 10, 2022 at 23:24 UTC | |
by Tux (Canon) on Aug 11, 2022 at 07:00 UTC | |
by LanX (Saint) on Aug 11, 2022 at 13:53 UTC | |
by Fletch (Bishop) on Aug 11, 2022 at 14:01 UTC | |
by GrandFather (Saint) on Aug 12, 2022 at 03:53 UTC | |
Re^5: How has your coding style changed over the years?
by GrandFather (Saint) on Aug 12, 2022 at 03:57 UTC | |
by Tux (Canon) on Aug 12, 2022 at 06:12 UTC | |
Re^5: How has your coding style changed over the years?
by Anonymous Monk on Aug 11, 2022 at 11:51 UTC |