gofmt

Adam D. Ruppe destructionator at gmail.com
Sat Apr 23 07:37:08 PDT 2011


> http://golang.org/cmd/gofmt/

Oh my. Check this out:

  Examples

  To check files for unnecessary parentheses:

  gofmt -r '(a) -> a' -l *.go

  To remove the parentheses:


What a scary example. What an AST considers unnecessary parenthesis
is probably very different from what I consider unnecessary.

I like to use a lot of parenthesis. Sometimes I don't remember the
precedence rules exactly, sometimes I like them as easy anchors
in case I change the code, and sometimes they serve no purpose
except visual grouping (often when combined with some whitespace).


I think a program like this would make code less readable.
Thankfully, the parens thing is just an example of a custom
user rule*, but that it's the one they gave on the manual scares
me that people actually would do that.

Style has rules to follow, but it has exceptions too. Computers
and humans are comfortable reading different things.

* If there's custom rules, will the code still be formatted in a
  standard way?


More information about the Digitalmars-d mailing list