new DIP47: Outlining member functions of aggregates

Jacob Carlborg doob at me.com
Tue Sep 10 00:59:32 PDT 2013


On 2013-09-09 22:01, Andrej Mitrovic wrote:

> You could use compile-time introspection where the API would look like:
>
> class C
> {
>      void foo();
>      void foo() { }
>      void bar() { }  // missing declaration
>      mixin VerifyDeclarations;
> }
>
> And this would statically assert if there's a missing declaration for
> a definition. I think this might even be doable with the current
> introspection features, although I'm not sure whether we have a way to
> determine if something is a declaration or a definition. Certainly
> such a trait could easily be added to the compiler.

A mixin should not be necessary. RTInfo can be used for that:

https://github.com/D-Programming-Language/druntime/blob/master/src/object.di#L575

The compiler will instantiate RTInfo once for each user defined type. 
The only downside is that you need to modify druntime.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list