Proposed improvements to the separate compilation model

Andrej Mitrovic andrej.mitrovich at gmail.com
Sat Mar 2 21:35:57 PST 2013


On Friday, 22 July 2011 at 22:06:20 UTC, Andrei Alexandrescu 
wrote:
> 1. The compiler shall accept method definitions outside a class.

Sorry to bump this old thread, but after having spent some time 
with D I like the idea of having the ability to implement class 
methods outside of the class, but I would like to have this 
ability in the same file as the module:

module test;

class C
{
     void foo1();

     void bar1()
     {
         // N1 -- two indents
     }

     class Inner
     {
         void foo2();
         void bar2()
         {
             // N2 -- three indents
         }
     }
}

// if allowed:

void C.foo()
{
     // 1 indent
}

void C.Inner.foo2()
{
     // 1 indent
}

The benefit? Avoiding the indentation tax. I've come to find it 
really annoying that hundreds of lines of code end up being 
indented twice or more times. Changing the indentation setting is 
not a real solution, I like my indentation size the way it is, I 
just don't like being forced to indent too much because of the 
requirement to implement everything inline.


More information about the Digitalmars-d mailing list