-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Remove the need for semicolons #483
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
Comments
I've seen this discussed a few times in the D language, here's some links: http://forum.dlang.org/post/[email protected] http://forum.dlang.org/post/[email protected] There's been quite a few posts on the D forums about this, but the general consensus there seemed to be that it was not an win overall. |
semicolons are necessary for Zig's grammar. for example:
|
The only reasonable way to remove semicolons is to make newlines essentially behave like a statement terminator (effectively an implicit semicolon). This starts to feel like Javascript's automatic semicolon insertion. The only conflict with existing grammar is the implicit return when the semicolon is omitted. We would have to require somehting like the return :block syntax proposed in #346. While I at first did not like the implicit block-return syntax I have found it a joy to use. Then comes the issue of chaining calls:
I also like the visual cues provided by semicolons
|
I remember that old discussion in D language forum. Walter Bright answered:
http://forum.dlang.org/post/[email protected] Personally I do not care. Never perceived them as problem. |
I agree with Walter's conclusion |
Google begs to differ, and they debug a lot of hairy C++ code. They left these out of Go. |
@andrewrk I suggest reopening or accepting this proposal. The Rust-style block return syntax is gone, so there's no conflict with existing grammar. |
@RaphiJS6-13 I might have misspoke at the time, I'm not confident that it would not have implications on the grammar or rely on weird parsing logic like JS. Not all semicolons are redundant and even those that are can be useful. |
some_function()
(variable + 1).doSomething() This is ambiguous without semicolons. It could be some_function();
(variable + 1).doSomething(); or some_function()(variable + 1).doSomething(); |
@pfgithub No, I meant using line breaks to delimit statements, not automatic semicolon insertion. |
some_function()
(variable + 1).doSomething() shouldn't be ambiguous. nobody's trying to call a function with parens from a newline... i hope |
I don't understand the usefulness of semicolons other than making the compiler simpler to write, why can't we do away with them?
The text was updated successfully, but these errors were encountered: