indent style for D

Jonathan M Davis jmdavisProg at gmx.com
Sun Jan 29 16:20:07 PST 2012


On Sunday, January 29, 2012 23:44:25 Iain Buclaw wrote:
> On 29 January 2012 23:30, Matej Nanut <matejnanut at gmail.com> wrote:
> > I like the look of 8-space indents, but I don't see how I could pull
> > it off if I use object-oriented features. I use 8-space indents if I
> > code C, and it seems to work really well. But when you have a class,
> > and then maybe even an inner class, you practically start with 2
> > levels of indentation, and that's where half your "page" (screen) is
> > blank space!
> > 
> > What is a solution to this, apart from using 4-space indentation? To
> > not indent class declarations is kinda one.
> 
> The answer to that is that if you need more than 3 levels of
> indentation, you're screwed anyway, and should fix your program.  :o)

That doesn't hold for D. There are too many ways to legitimately end up with 
several levels of indentation. Templates, static ifs, version blocks, 
struct/class declarations, if/else, while, etc. 3 or 4 levels of indentation 
is not necessarily uncommon at all.

C has so few things that result in new blocks to indent, that the 3 levels of 
indentation rule has some merit there. But in OO languages (and especially in 
D with its additional conditional compilation features), that just doesn't fly.

- Jonathan M Davis


More information about the Digitalmars-d mailing list