Live data from Hacker News

Go Lang: Comments Are Not Directives

news.ycombinator.com

81–90 of 222 posts

Re: Go Lang: Comments Are Not Directives

#81
post #64
post #45

Lisp has used directives in comments in the past. Only on the first line of a file but they were parsed.

That had to be very distant past or some non-standard lisp. Common Lisp has no such feature.

It was done on Lisp Machines and currently in CCL.

Re: Go Lang: Comments Are Not Directives

#82
post #35

Earlier quoted context omitted.

Fully agree. I love Go and use it for anything related to servers or the web, but doing anything with comments besides just letting them be comments, is just braindead.

They aren't used by the compiler at all.

    //#cgo
    //go:nosplit
    //go:noescpae
are all used by the compiler in one way or another

Re: Go Lang: Comments Are Not Directives

#83

I also do not agree with that. This is bad for so many reasons. First, to the compiler code, comments should be discarded as soon as possible (often in the lexer). To the programmers, comments should never execute anything (this is just intuitively expected). To any go source code reader (human or machine), comments are supposed to contain only human readable text, probably a context sensitive explanation of that par…

the comment is not executed by the compiler, it's executed by the go tool

Re: Go Lang: Comments Are Not Directives

#84
post #77
post #69

Comments are just comments, we should not keep adding keywords and syntax to them. Go's backward compatible promise is hurting itself. By sticking with strict compatibility mode, ad hoc solutions for fundamental issues are added from time to time. Sooner or later, those patch works will back-fire. For a language so young (version 1.0 in 2012), they should keep compatibility for stable release (1.x), but start adding…

One of the best features of go is "go fix" Yea! A migration tool for the language it self? Before they need to worry about compatibility they can break a lot of stuff.

Yeah I know, we can easily fix the codes with tools, we also have tools for conversion between Python 2 and 3, right?

However, we can not easily fix the way people writing the code, or the so-called idiomatic Go norms.

Actually, it is compatibility in the ecosystem of Go packages that matters. We have lots of good Go packages on Github that are no longer compatible with Go 1.0/1.1/1.2 etc.

Re: Go Lang: Comments Are Not Directives

#86
post #24
post #3

(You left out "// +build", which predates Go 1.4.) We made the decision that "//go:" is the syntax for comment directives. The old ones stay around for compatibility reasons. Previous discussion: https://groups.google.com/forum/#!searchin/golang-dev/commen...

And there's //line path/to/file:linenumber and //go:noescape

Reminds me of typescript

///

Re: Go Lang: Comments Are Not Directives

#87

At last! I'm not insane! I raised this on the golang dev forums and got nowhere: https://groups.google.com/d/msg/golang-dev/r4rdPdsH1Fg/yjOOz... The response was basically "we disagree" and I wandered away feeling confused that so many bright people couldn't see the problem here.

> The response was basically "we disagree" and I wandered away feeling confused that so many bright people couldn't see the problem here.

That's a rather disingenuous summary given that literally the very first response is Brad Fitzpatrick from the Go team agreeing with you, acknowledging that it's unfortunate, and admitting that it can't feasibly be changed yet due to the compatibility guarantees. And then shortly afterwards, he encourages you to bring this point up when Go 2 comes around.

Re: Go Lang: Comments Are Not Directives

#90
Meh. I hear your gripe, but I think your proposed solution is not that much of an improvement. You're also basing all of this on the idea that comments are "free form". Where is that gospel? I like the idea that comments are more than just blabber. I like the idea that, when structured some way, they take on new meanings.

I think this is a semantic argument.

Post reply on HN