Implicit instantiation of parameterless templates

Piotr Szturmaj bncrbme at jadamspam.pl
Fri Oct 5 13:07:36 PDT 2012


F i L wrote:
> Dmitry Olshansky wrote:
>> Hm... If placed at the global scope it looks like a namespace.
>
> I don't see anything wrong with that. It's just another way (somewhat
> unique to D) you can categorize your code. Most people probably won't
> use this sort of thing all over the place, but it actually might be
> useful for "enforcing" naming classifications:
>
>      // File system/io.d
>
>      template Console
>      {
>          void write( ... )
>          void read()
>      }

final abstract class Console
{
     static:
     void write() { }
     void read() { }
}

Console.write();

P.S. Yes, simultaneous final and abstract actually works :)


More information about the Digitalmars-d mailing list