-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
optional end
for single-expression, one-line block bodies
#1657
Comments
Personally, I don't really like the single line
|
I was gung-ho for that a long time ago, but my ardor has cooled somewhat. A lot of people seem to find that very hard to read. |
I can't say I care for this. At least with the reversed-order Perl/Ruby style, you know that if you flip it you need to group the statements. This sounds as prone to error as the optional curlies around single-statement |
I'm not sure where the errors might come from. How do you mean? It's interesting to get feedback on this idea, which has kind of been bouncing around my brain for a while. |
I'm not sure about errors, but I find the optional curlies in C very confusing. |
I don't find the optional curlies confusing, but it did once screw me over badly in 1998. I've managed to remain unaffected by them since then. |
Wow, that must have been a traumatic incident :) |
Worst bug hunt I've ever experienced. It took me a week to track down a single stray semicolon. |
Errors in editing, particularly editing code you're not familiar with. https://www.google.com/search?q="optional+curly+braces"+problem gives a few links, and I know I've run into this in C myself. It just seems like a hair too much rope just to make short lines even shorter. If you wanted that, you should have gone with layout instead of Also: pesky semicolon. Been there, done that too. |
In Fortran only simple ifs without else clauses can be written on a single line without endif
are very useful and readable in my practice. |
E.g., allow these:
Since we would still allow
end
on single-expression, one-line block bodies, this wouldn't break any code, but I think it really makes a lot of things like this look better. Compare to how the above have to be written now:The text was updated successfully, but these errors were encountered: