Me, Leslie and Ron
-
@Maciejasjmj said in Me, Leslie and Ron:
@Fox said in Me, Leslie and Ron:
That's the way the indentation and line spacing is structured; as if every else in else if is a new else{} block containing an if{} and another else{}.
Isn't that also how it works, abusing the "else can have a single statement without braces after it" rule of most programming languages? Sure,
else if
is an idiom, but it's not a dedicated language construct from what I know.It is in Go.
if
requires braces around its body,else
requires braces around its body, butelse if
only requires one set of braces.
-
@RaceProUK said in Me, Leslie and Ron:
@Zecc said in Me, Leslie and Ron:
Perl'
elsif
.That just looks like someone @accalia'd the name
elsie
@aliceif is probably a Perl keyword.
-
@RaceProUK
Whenever I see something like that I usually nuke it from orbit.
-
@abarker said in Me, Leslie and Ron:
How do you quickly scan through and find the else statement that matches an if statement?
Why do you need to?
@abarker said in Me, Leslie and Ron:
How do you easily find the end of a conditional block?
just look. It's not that hard
-
@RaceProUK said in Me, Leslie and Ron:
if (Programming style == the way God intended)
{
braces.style = "Egyptian";
}
else
{
user.type = "Barbarian";
}Or this:
if (Programming style == the way God intended) { braces.style = "I see seagulls" } else { user.type = "on the horizon"; }
-
@JBert said in Me, Leslie and Ron:
Did you mean
if ( Programming style == the way God intended ) { braces.style = "Egyptian"; } else { user.type = "Barbarian"; }
-
@Mikael_Svahnberg What about
if (Programming style == the way God intended) { braces.style = "I see seagulls"; } else { user.type = "on the horizon"; }
???
I did consider using 3-space tabs, but that would be insane ;)
-
Serious question: why doesn't anyone style ifs/fors/whiles like this?
if( parenthesesPadding == 1 && parenthesesMargin == 0 ){ ++zecc.Happiness; }
-
@Zecc It just looks weird. I much prefer this:
if (parenthesesPadding == 0 && parenthesesMargin == 1) { hedgehog.Happiness++; }
in JavaScript no matter the size of the body, and in C#, this:
if (parenthesesPadding == 0 && parenthesesMargin == 1) { hedgehog.Happiness++; }
or, for a single-line body, this:
if (parenthesesPadding == 0 && parenthesesMargin == 1) hedgehog.Happiness++;
Go consistency! :D
-
@RaceProUK Yeah, the top one...
if (parenthesesPadding == 0 && parenthesesMargin == 1) { this.Happiness++; }
-
@RaceProUK said in Me, Leslie and Ron:
It just looks weird.
Because you're not used to it, I wager.
I think it separates better the boilerplate from the juicy bits. Personal opinion, of course.I write not-personal code like you do, because indeed consistency.
Also because ain't nobody got time to mess around with editor settings.
-
@Zecc said in Me, Leslie and Ron:
@JBert said in Me, Leslie and Ron:
Did you mean
if ( Programming style == the way God intended ) { braces.style = "Egyptian"; } else { user.type = "Barbarian"; }
What?
The bottom code block is just using barbaric indentation, though some keep stating that it's perfectly acceptable.
Filed under: Somebody noticed!, Have an Internet cookie
-
3 spaces seem just perfect. They give you enough space to quickly identify nested blocks, but not so much that after two or three level of nesting your code reaches the right margin of the screen.
If you're hitting the right margin after just two or three levels of nesting, your code lines are too long. Either that, or your screen is stupidly narrow.
-
I think that a large number of developers is moving away from tabs, and for a very good reason. When you use the tab, even if you have just a couple of nested blocks (like an if inside a for) your code is already gone well past the middle of the screen
A large number of developers know how to change the tab size to 4. Or 2. Or 3 if that's what they want.
-
@Zecc said in Me, Leslie and Ron:
When you use the tab, even if you have just a couple of nested blocks (like an if inside a for) your code is already gone well past the middle of the screen
Are these people using like 640x480 displays or something?
-
@loopback0 said in Me, Leslie and Ron:
@Zecc said in Me, Leslie and Ron:
When you use the tab, even if you have just a couple of nested blocks (like an if inside a for) your code is already gone well past the middle of the screen
Are these people using like 640x480 displays or something?
ALL LINES MUST BE NO MORE THAN 80 CHARACTERS!!!
-
@Jaloopa said in Me, Leslie and Ron:
@loopback0 said in Me, Leslie and Ron:
@Zecc said in Me, Leslie and Ron:
When you use the tab, even if you have just a couple of nested blocks (like an if inside a for) your code is already gone well past the middle of the screen
Are these people using like 640x480 displays or something?
ALL LINES MUST BE NO MORE THAN
80120 CHARACTERS!!!FTFPWMFTTFC
-
-
@Mikael_Svahnberg said in Me, Leslie and Ron:
@ben_lubar said in Me, Leslie and Ron:
@izzion said in Me, Leslie and Ron:
if ( Programming style == the way God intended ) { braces.style = "Egyptian"; } else { user.type = "Barbarian"; }
if parentheses == "unnecessary" { go func() { fmt.Println("why are we writing code like this") }() } else { panic("OH GOD BEN L IS POSTING GO AGAIN") }
(when (eq (proper) (language)) (message "Clearly, the parenthesis should go *before* the if statement."))
-
@Zecc said in Me, Leslie and Ron:
Serious question: why doesn't anyone style ifs/fors/whiles like this?
if( parenthesesPadding == 1 && parenthesesMargin == 0 ){ ++zecc.Happiness; }
I've interned at a suprisingly non- company where the coding style was
object.methodCall (arguments);
-
@Jaloopa said in Me, Leslie and Ron:
ALL LINES MUST BE NO MORE THAN 80 CHARACTERS!!!
Python insists on that despite not having braces at all.
-
@loopback0 said in Me, Leslie and Ron:
@Zecc said in Me, Leslie and Ron:
When you use the tab, even if you have just a couple of nested blocks (like an if inside a for) your code is already gone well past the middle of the screen
Are these people using like 640x480 displays or something?
More like 480x640. Everything's MobileTM now, you know?
-
-
@Zecc said in Me, Leslie and Ron:
Serious question: why doesn't anyone style ifs/fors/whiles like this?
if( parenthesesPadding == 1 && parenthesesMargin == 0 ){ ++zecc.Happiness; }
if( conditionalsPadding==1 && parenthesesMargin==0 ){ fox.happiness++; }else if(parenthesesMargin==0){ fox.happiness++; }else{ fox.happiness--; } if( indentType=="space" || indentSize!=4 ){ fox.happiness-=2; } if(fox.happiness<1){ fox.display(sadfox.png); }else{ fox.display(thumbsupfox.png); }
My preferred style , I generally don't care about having space around conditional operators, but rather separating out individual rules when there's more than one, as well as around sets of coinciding if-else blocks. I actually prefer grouping up both sides of each individual rule and grouping up related if's, else if's, and else's. Also if you use spaces instead of tabs for indentation without a good reason for doing so, I will stab you in the eyes with hot cheetos.
-
@Fox said in Me, Leslie and Ron:
if( indentType=="space" || indentSize!=4 ){
fox.happiness-=2;
}8 shall be the size of thine tab stops, and the size of thine tab stops shall be 8.
-
@PleegWat The size of your tabs will be precisely ONE TAB
-
@loopback0 said in Me, Leslie and Ron:
@PleegWat The size of your tabs will be precisely ONE TAB
Your indentations shalt be one tab, no more, no less. One tab shall be thy indentations, and the size of the indentation shall be be one tab. Two tabs shalt thou not indent, neither indent thou zero tabs, excepting that thou then proceed to one tab. Spaces are right out.
-
@abarker said in Me, Leslie and Ron:
@loopback0 said in Me, Leslie and Ron:
@PleegWat The size of your tabs will be precisely ONE TAB
Your indentations shalt be one tab, no more, no less. One tab shall be thy indentations, and the size of the indentation shall be be one tab. Two tabs shalt thou not indent, neither indent thou zero tabs, excepting that thou then proceed to one tab. Spaces are right out.
You python killer you!
-
@dcon said in Me, Leslie and Ron:
@abarker said in Me, Leslie and Ron:
@loopback0 said in Me, Leslie and Ron:
@PleegWat The size of your tabs will be precisely ONE TAB
Your indentations shalt be one tab, no more, no less. One tab shall be thy indentations, and the size of the indentation shall be be one tab. Two tabs shalt thou not indent, neither indent thou zero tabs, excepting that thou then proceed to one tab. Spaces are right out.
You python killer you!
-
@PleegWat said in Me, Leslie and Ron:
@Fox said in Me, Leslie and Ron:
if( indentType=="space" || indentSize!=4 ){
fox.happiness-=2;
}8 shall be the size of thine tab stops, and the size of thine tab stops shall be 8.
Artist's rendition of you when i'm through with you:
-
@Zecc said in Me, Leslie and Ron:
Serious question: why doesn't anyone style ifs/fors/whiles like this?
if( parenthesesPadding == 1 && parenthesesMargin == 0 ){ ++zecc.Happiness; }
I do. I find it more readable to put spaces on the inside of the parentheses.
-
@boomzilla said in Me, Leslie and Ron:
I find it more readable to put spaces on the inside of the parentheses.
Hmph. And to think I used to like you.
-
@PleegWat said in Me, Leslie and Ron:
@Fox said in Me, Leslie and Ron:
if( indentType=="space" || indentSize!=4 ){
fox.happiness-=2;
}8 shall be the size of thine tab stops, and the size of thine tab stops shall be 8.
no. 8 is insane. 4 is correct.
addendum: we use a 3rd party set of controls for dot net pages, and those guys really love having internal tags for stuff. it's so bad, at the default 4-space tab stops we'll have markup indented to the right edge of the editor. I have markup tabs set to 2 spaces to keep a handle on it.
-
@Fox said in Me, Leslie and Ron:
@PleegWat said in Me, Leslie and Ron:
@Fox said in Me, Leslie and Ron:
if( indentType=="space" || indentSize!=4 ){
fox.happiness-=2;
}8 shall be the size of thine tab stops, and the size of thine tab stops shall be 8.
Artist's rendition of you when i'm through with you:
You're going to give him bad makeup?
-
if ( codingStyle == "this bullshit " ) {
-
-
@Fox said in Me, Leslie and Ron:
if( conditionalsPadding==1 && parenthesesMargin==0 ){ fox.happiness++; }else if(parenthesesMargin==0){ fox.happiness++; }else{ fox.happiness--; }
I bet it's a matter of time before someone points out your first conditional and branch is redundant given the second conditional and its branch.
-
@Fox said in Me, Leslie and Ron:
if(fox.happiness<1){ fox.display(sadfox.png); }else{ fox.display(thumbsupfox.png); }
I can definitely imagine a library where
.png
,.jpg
,.gif
etc. are properties of an image class where the getter encodes the image in that format and the setter decodes from that format.Filed under: thinking too much about this
-
@boomzilla said in Me, Leslie and Ron:
@Zecc said in Me, Leslie and Ron:
Serious question: why doesn't anyone style ifs/fors/whiles like this?
if( parenthesesPadding == 1 && parenthesesMargin == 0 ){ ++zecc.Happiness; }
I do. I find it more readable to put spaces on the inside of the parentheses.
But do you leave out the spaces outside the parens?
OK let me rephrase that. Do you put spaces between the if keyword and first opening parens, and between the last closing parens and the opening brace?
-
@Zecc said in Me, Leslie and Ron:
I bet it's a matter of time before someone points out your first conditional and branch is redundant given the second conditional and its branch.
None of that matters when you're barbarian enough to post-increment.
Hmm...does anyone remember the guy who was really adamant about post-incrementing in for-loops? Ah ha!
Start here:
https://what.thedailywtf.com/post/167480Now that's a classic thread!
-
@Zecc said in Me, Leslie and Ron:
But do you leave out the spaces outside the parens?
OK let me rephrase that. Do you put spaces between the if keyword and first opening parens, and between the last closing parens and the opening brace?
Mostly, yeah, I leave the spaces out. Certainly no space between the
if
and the opening paren. An extra space between the closing paren and the opening brace doesn't bother me, but by default I'd leave it out.
-
+1
@boomzilla said in Me, Leslie and Ron:
None of that matters when you're barbarian enough to post-increment.
-
Not to be confused with post-excrement.
-
@Zecc also not to be confused with posting excrement.
-
@Zecc said in Me, Leslie and Ron:
@Fox said in Me, Leslie and Ron:
if(fox.happiness<1){ fox.display(sadfox.png); }else{ fox.display(thumbsupfox.png); }
I can definitely imagine a library where
.png
,.jpg
,.gif
etc. are properties of an image class where the getter encodes the image in that format and the setter decodes from that format.Filed under: thinking too much about this
Meanwhile I was thinking of it as a 2D game engine wherein the
.display(<img>)
function displayed the specified image at the screen location stored in the objectfox
.
-
@boomzilla said in Me, Leslie and Ron:
None of that matters when you're barbarian enough to post-increment.
Hmm...does anyone remember the guy who was really adamant about post-incrementing in for-loops? Ah ha!It matters even less when you're barbarian enough to be elitist about post- or pre-incrementing in for loops when, as was even identified in that classic thread almost six years ago, both compile to the same thing.
-
@Zecc said in Me, Leslie and Ron:
@Fox said in Me, Leslie and Ron:
if( conditionalsPadding==1 && parenthesesMargin==0 ){ fox.happiness++; }else if(parenthesesMargin==0){ fox.happiness++; }else{ fox.happiness--; }
I bet it's a matter of time before someone points out your first conditional and branch is redundant given the second conditional and its branch.
Hush you! I was just trying to keep the code simple while still providing an example of where there was only one conditional statement in the parentheses, which is a case in which I am okay with there being no spaces within or around the parentheses.