gofmt

Matthew Ong ongbp at yahoo.com
Thu May 12 07:53:32 PDT 2011


On 4/23/2011 10:37 PM, Adam D. Ruppe wrote:
>> 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?

Hi,

yes, I like to C/C++/C#/Java syntax style. But gofmt the formatting is a 
good idea. Something to help developer to find missing (){} or such way 
is import help and also layout of indentation. As for Java, Sun used to 
defined a common coding standard and also naming convention
so that developer can easily navigate the huge API tree without much 
help. As for D, currently I am using  grepWin to learn how D does it.

-- 
Matthew Ong
email: ongbp at yahoo.com



More information about the Digitalmars-d mailing list