new DIP47: Outlining member functions of aggregates

Adam D. Ruppe destructionator at gmail.com
Sat Sep 7 13:17:11 PDT 2013


Like I said in Manu's thread, we can actually do this already, 
via pragma(mangle) hacks. That's brittle, the compiler doesn't 
tell you if you messed up the signature, but it works and gives 
answers to a lot of the questions in this thread.

class A {
    void foo();
}

pragma(mangle, A.foo.mangleof)
void foo_impl(A _this) {}


That's compile and run today. Things to note:

* The name is figured out by regular importing rules. A is 
whatever A is in schope.

* foo_impl might as well not exist as far as the outside world is 
concerned. It just is A.foo.

* I think the privacy should work this same way too: if it is in 
the same module, it can see private members, if not, it can't.


More information about the Digitalmars-d mailing list