[OT] Auto code reformating / one coding style enforcment.

kris foo at bar.com
Sat Aug 12 14:27:21 PDT 2006


Dawid Ciężarkiewicz wrote:
> This is *not* proposition of D change. Only free concept that I wish to
> share with D users.
> 
> Most of the time of my coding work I'm dealing with code that I didn't
> wrote. What is most irritating is when I just can't reformat code using
> indent or astyle because I need to work on little change and produce diff
> that will fit into original repository. And sometimes code is completely
> mess - I don't care if someone likes breaking brackets here and there,
> but ... I thing you all know what I'm talking about.
> 
> My thoughts are always like this: why creators of C language allowed people
> to format code freely? Wouldn't world be a better place if languages would
> enforce their one-true-coding-style? If there would be no choice there
> would be no reason to argue.


lol ... because there would never be a unanimous concensus on what that 
format should be ;D

You may recall the beating Fortran took because of the need to place 
variable-decls on the sixth column only (or something like that).

Python uses syntactically significant indentation (for blocks), instead 
of braces. Because of that, the language attracts a lot of flack from 
various quarters.



> "If I'd write my own language ..." (don't get it too serious - it's only
> hypothetical ;-) ) there would be no way to code same code in two different
> ways (except of identifier names, comments and such ...). There would be
> one standard and compiler would enforce it - throwing errors about code
> formating or even reformat code in the fly if asked to (optional switch or
> something like that).
> 
> The users would have to adopt to code in such language - get used to one
> coding style, which probably wouldn't be what they were doing before in
> every aspect, but ...
> 
> ... after some time they would discover that when they look at someone else
> code in that language - there is no difference. Working with patch/diff
> tools is nicer, reading code pleasure is bigger. Everything is better ...
> 
> Python code tries to enforce coding style rules - I like that aspect of it.
> What I don't like is not enforcing to use tabs for indentation and which is
> even worse - not enforcing on _any_ standard about indentation, only to be
> consistent in whole source file. Except that I'm not aware of any language
> (except Whitespace ;-) ) that do something similar. Have anybody even
> tried? Did such language succeed?
> 
> What do you think? 


As long as anyone considers writing code to be an "expression" or "art 
form", to any degree, the notion of a single writing format (upon which 
everyone will agree) is doomed to failure :)

There have been strict rules regarding the use of grammar, prose, and 
sentence structure for centuries ... yet, it seems those are abandoned 
on an accelerating basis :p




More information about the Digitalmars-d mailing list