-
Notifications
You must be signed in to change notification settings - Fork 4k
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
[Proposal] Automatic Semicolon Insertion in C# #5355
Comments
To quote what was already said on this subject from CodePlex:
|
@HaloFour Can you please link discussion from codeplex? I am unable to find it by its fragments. But it is definitely worth to be able to track previous discussion on the same issue. Second case is perfectly reasonable. Also: I definitely agree that breaking reverse compatibility for such a minor improvement is a horrible idea, but if one day someone decides to make some other breaking changes this one might be worth considering. |
Remove requirement for semicolon (;) at end of line It's also come up a couple of times embedded in other issues/discussions. You can't make the semicolon implicit without adding some form of significant whitespace, which will change the semantics of existing code. The following would become ambiguous: for (int i = 0; i < 10; i++)
a += b; In my opinion it doesn't make sense to change the syntax of C# to match that of another language just for the sake of doing so. Adoption of features from other languages is one thing, but making C# smell like JavaScript, Scala or Python syntactically adds nothing to C#. |
Also search for "semicolon" in the mega-thread #2136. |
I'm not using semicolons in JavaScript anymore because the code looks much cleaner but I really don't want to see C# look like JavaScript, in C# these semicolons are consistent you either add them or you don't, I don't like the option in-between these two extremes very much, just my opinion. :) |
One day I wrote the following code in javascript return
{
a: 0
} And I was toasted. No, please. |
Coding style matters because it reflects the best practices for each language. In JavaScript, one should write code with opening curly braces on the line of the statement blog belongs to:
That solves @DiryBoy's problem. But I wouldn't touch @eyalsk's JavaScrpt code even with a 10 foot pole. |
@paulomorgado http://stackoverflow.com/questions/3048800/how-can-i-set-visual-studio-to-use-kr-style-bracketing IMHO that's not @DiryBoy 's problem, it's a bug in the language design. The language should decide whether it has significant whitespace or not. |
@paulomorgado so don't use NPM please because they are doing that too! why semicolons are so precious to you? my code is well covered with tests so how come semicolons make such a difference to you? it's really interesting to know the reason. |
@eyalsk Certain unit tests are merely a workaround for a lacking type system (even in C#). The more can be handed over to static analysis the better. |
@dsaf Yeah, I was one of the first people to use CodeContracts when it was published, I know about that but @paulomorgado was speaking about my JavaScript code due to lack of semicolons. If you understand ASI and you make sure your code is properly linted and you do your tests properly there's no need for semicolons, again, when we're speaking about JavaScript. |
Iff you want to do this, Scala's Semicolon Inference might be a lot better role model than ECMAScript's Automatic Semicolon Insertion. However, please note: Even though
there are still cases where Semicolon Inference can surprise you, if you don't follow the official Scala style guide. |
Swift does this very well for me. |
This might be a bit controversial :). But is there any good reason why there is no ASI in C#? I am curious if rules for ECMA Script http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf chapter 11.9 could also work in C#?
From practical point of view code without semicolons in Javascript/Typescript looks leaner and it is possible to write thousands of lines of code without using single semicolon (not counting
for (;;)
)The text was updated successfully, but these errors were encountered: