Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: A Question of style.

by kirbyk (Friar)
on Jun 06, 2005 at 21:40 UTC ( #464097=note: print w/ replies, xml ) Need Help??


in reply to A Question of style.

Yes, as people say, this is one of those things were TMTOWTDI really is true.

I will say, the one concrete thing (as opposed to just preference) I like about having the { on the same line of a sub or an if:

If it's a longer sub or if block, and I'm at the closing }, I can hit % in vi, and it takes me to the matching one. If it's on the same line, I see the sub name or conditional on the screen, which is _exactly_ what I want. If it's on the next line, I have to then scroll up a line to see, and the next thing I'm usually going to want to do after seeing that is % back to the end brace (to go back to where I was.) So, it annoys me to no end when people put them on the next line.

-- Kirby, WhitePages.com


Comment on Re: A Question of style.
Re^2: A Question of style.
by GrandFather (Cardinal) on Jun 06, 2005 at 21:50 UTC
    Ahhh, at last a reason for K&R indentation (albeit a bit cart before the horse).

    Food for thought, not fuel for flames.
Re: A Question of style.
by jonadab (Parson) on Jun 07, 2005 at 10:38 UTC
    If it's a longer sub or if block, and I'm at the closing }, I can hit % in vi, and it takes me to the matching one. If it's on the same line, I see the sub name or conditional on the screen, which is _exactly_ what I want. If it's on the next line, I have to then scroll up a line to see, and the next thing I'm usually going to want to do after seeing that is % back to the end brace (to go back to where I was.) So, it annoys me to no end when people put them on the next line.

    Can't you just rebind the % key so that (in addition to what it usually does) it checks that the line it is on is not the first or last line in the buffer, scrolling one line if necessary to accomplish that? vim fans claim it's pretty customizable, so one would think that would be easy (though, not being a vi user myself, I'm speculating here).

    (Of course, I prefer the behavior wherein the editor shows the line containing the opening brace in the status area when your cursor rests after the closing brace, so you don't have to hit a key in the first place, which brings us back to your argument, since there's not room in the status area for two lines without expanding it, which is a bit jarring.)

    My own reason for preferring nestled braces in most cases is that it makes the code significantly more vertically compact, which allows a lot more context to fit on the screen at once, making the code easier to follow, since you can see more with less scrolling about.


    "In adjectives, with the addition of inflectional endings, a changeable long vowel (Qamets or Tsere) in an open, propretonic syllable will reduce to Vocal Shewa. This type of change occurs when the open, pretonic syllable of the masculine singular adjective becomes propretonic with the addition of inflectional endings."  — Pratico & Van Pelt, BBHG, p68

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://464097]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2014-07-26 13:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (177 votes), past polls