D-Programming-Language/dmd — pull request #3005 by yebblies (2013-12-22 06:11:28+00:00)
Title: [DDMD] Use factory functions instead of calling constructors from the glue layer

D and C++ constructors have an important difference: D expects the memory to already contain `.init`, C++ constructors do not. This makes calling D constructors from C++ much more complicated than simply matching mangling, unlike other functions.

This pull avoids the problem by defining factory functions which `new` the structs/classes from the D side, guaranteeing correct initialization and use of the correct heap.

My hope is that the dmd glue layer will eventually be converted to D and/or all ast class creation will be removed from the glue layer.

I'm open to other ideas, but this problem need to be fixed one way or another.