From a language perspective the above should be legal Go code.
It was designed to simplify go's compiler programming. It was not designed for programmers' programming.
gofmt
's style is as good as any other."http://golang.org/doc/faq#semicolons
-rob
Hi Rob,
In that reference it says, "Go is a new language andgofmt
's style is as good as any other."
I totally disagree. K&R style does not clearly show the alignment of blocks of code as the Allman style does. That has always been my problem with K&R - the Allman style is more readable.
While it is obvious people disagree and are welcome to their opinion - this should not be something enforced by the language. The language should enforce the semantics of the tokens, not whether a token should be placed on the current line or the next line. Rather ridiculous rule if you ask me... I do believe that will hurt adoption of the language - and, IMO, I think it is a very poor decision on the part of the language designers.
Adoption is not a single event... it is an ongoing continuum.
This absolutely will hurt adoption because it is foolish enforcement with no good reason. It is "because I said so" enforcement. It may not matter to many people, but it will to some.
So, how much adoption is hurt by it is irrelevant, the fact remains that it will hurt adoption which is why I consider it a poor design choice.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
On Sat, Sep 21, 2013 at 6:58 PM, Michael Daconta
<michael...@gmail.com> wrote:
> Hi Remy,
>
> I was not precise enough - instead of language spec - I should have said
> language grammar.
> Semi-colon insertion is a convenience and cannot be part of the language
> grammar.
No one ever said that semicolon insertion is part of the language
grammar. Actually, semicolon injection is part of the language
specification.
> Certainly semi-colons are part of the language grammar.
Correct.
> I will look at the language grammar in detail - my gut feeling is that this
> program:
>
> package main;
>
> import "fmt";
>
> func main()
The above line is seen, according to the specs, by the compiler as:
func main();
> {
> fmt.Printf("hello, world!\n");
> }
I do see the part of the spec you are referring to regarding the semi-colons; however, that verbiage is not really the grammar. The Grammar is the EBNF notation.
Function = Signature FunctionBody
The parsing rules for go, which mandate the implicit semicolons, require that the second here is a syntax error. I get that you don't like the language's grammar, but I don't think you understand that to grammar is perfectly clear, and does in fact prohibit one of these.
Ok, I understand your sentiment but you have not answered the question beyond the assertion that "it doesn't matter."It doesn't matter - to you. Maybe this is a philosophical point - why would a language design enforce a feature that has no bearing on the compilation of the code?From a "language-legality standpoint" -why isfunc main() {}legal andfunc main(){// tbd}not legal? Both declare a function and both assert the start and end of the function. A programming language is a language and language is supposed to make sense in regards to its intended purpose.
--- Mike
On Saturday, September 21, 2013 10:51:16 AM UTC-4, Volker Dobler wrote:Am Samstag, 21. September 2013 15:50:31 UTC+2 schrieb Michael Daconta:
Adoption is not a single event... it is an ongoing continuum.
This absolutely will hurt adoption because it is foolish enforcement with no good reason. It is "because I said so" enforcement. It may not matter to many people, but it will to some.
So, how much adoption is hurt by it is irrelevant, the fact remains that it will hurt adoption which is why I consider it a poor design choice.And blue bike sheds won't help adoption of bike-to-workfor those who insist on red sheds...Just stay away if you really cannot cope with Go.V.
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
What is this preprocessor of which you speak? There is no preprocessor.
I think this may be at the root of your confusion. In C, there is conventionally a preprocessor which has nothing to do with the specification of the language itself. You seem to be thinking that go is similar, and that some preprocessor is doing the semicolon insertion as some kind of convenience feature. But that is not correct. Go has no preprocessor, and the semicolon insertion is as integral to the language as the use of range in for statements or the specification of "chan" as a reserved word.
Thomas
--
You are incorrect. It is a formal part of to language, and there is no preprocessor in Go.
You're incorrect. It is specified by the entire text of the specification, and not by some subset you've chosen.
--
The language is specified by the EBNF grammar and nothing else in terms of what the compiler should accept as a "legal" program.
Hi Go fans,I frankly was shocked to learn that a program like:
package main;import "fmt";func main(){fmt.Printf("hello, world!\n");}
... is currently illegal in go with the error:# command-line-arguments.\hello.go:6: syntax error: unexpected semicolon or newline before {From reading the newsgroups, I see that this is illegal due to the automatic insertion of semi-colons; however, what if I added my own semi-colons into the code as in the above. From a language perspective the above should be legal Go code. To me, it seems like a hack for convenience (making semi-colons optional) has forced a K&R style on everyone.For me, this is a show-stopper. Frankly, I am surprised that Google would enforce a coding style (K&R) while saying that "go fmt" frees you from worrying about divergent coding styles. Sorry, google - you cannot have it both ways. Unless the Allman-style code above is illegal in the language (which makes no sense from a language semantics point of view) - get the compiler to accept it. Period.Yes, I know I can write my own translator - but why? Heck, I can just stick with Java...C'mon Google, when trying to pitch a new language, you can (and should) do better than this...- Mike
Good points and you are right about Java - though I always used Allman style when programming in Java and in C.Preferences aside, I did take the opportunity to cobble together a Go program that uses text/scanner to reformat the code.Not pretty but it was fun even playing with Go a little bit to get a basic program working.I may improve it over time and continue to pick up Go little by little...
Hi Rog,The language is specified by the EBNF grammar and nothing else in terms of what the compiler should accept as a "legal" program.
For me, this is a show-stopper.