Coding Standards

Johann MacDonagh johann.macdonagh.no at spam.gmail.com
Sun Jul 17 13:56:27 PDT 2011


On 7/17/2011 4:53 PM, bearophile wrote:
> Walter:
>
>> bearophile:
>>> But not using a standard with a bit more energy will be one of the faults of D.
>>
>> There is a D style guide. I really don't understand what you're complaining about.
>
> This blog post is about Gofix, a Go standard library tool, it seems one possible answer:
> http://blog.golang.org/2011/04/introducing-gofix.html
>
>> Gofix is a new tool that reduces the amount of effort it takes to update existing code. It reads a program from a source file, looks for uses of old APIs, rewrites them to use the current API, and writes the program back to the file. Not all API changes preserve all the functionality of an old API, so gofix cannot always do a perfect job. When gofix cannot rewrite a use of an old API, it prints a warning giving the file name and line number of the use, so that a developer can examine and rewrite the code. Gofix takes care of the easy, repetitive, tedious changes, so that a developer can focus on the ones that truly merit attention.<
>
>> Gofix is possible because Go has support in its standard libraries for parsing Go source files into syntax trees and also for printing those syntax trees back to Go source code. Importantly, the Go printing library prints a program in the official format (typically enforced via the gofmt tool), allowing gofix to make mechanical changes to Go programs without causing spurious formatting changes. In fact, one of the key motivations for creating gofmt—perhaps second only to avoiding debates about where a particular brace belongs—was to simplify the creation of tools that rewrite Go programs, as gofix does.<
>
> Bye,
> bearophile


So you're saying a style guide would help to create a tool like DFix?

Wouldn't it be better to have a lexer and parser to do this for you (btw 
I'm working on std.lang.d.lexer).


More information about the Digitalmars-d mailing list