Hacker News new | ask | show | jobs
by snogglethorpe 4842 days ago
> > the colon vastly improves readability

> We have gofmt for that :)

Er, what? gofmt doesn't improve the readability of declarations at all... [there's really not much it can do]

1 comments

It spaces them evenly if you have multiple subsequent lines of them. Readable enough:

    var (
        i, j        int
        foobarStuff string
        bebop       bool
    )
What's not readable?
Er, ok, it can slightly mitigate the problem in a few cases. Even to the extent that it work though, this is a very fragile "solution" — (1) declarations often occur alone, (2) multiple declarations can have similarly sized variables, meaning there's no big whitespace chunk to act as a separator, and (3) one shouldn't have to run one's code through a code formatter, or use awkward formatting practices, to get basic readability....

Simply following standard practice (over decades), and including a colon, on the other hand, would have made all declarations more readable, and be more familiar, for no real cost.

Really, some of Go's syntax decisions are completely baffling...

[Sure there are lots of crazy computer languages around, but these guys really should have known better—and anything they do is much more likely to have an impact than most random languages, so it'd be nice if they could take a bit more care...]