Leandro Lucarella wrote:
Andrei Alexandrescu, el 7 de octubre a las 15:23 me escribiste:
You seem to be asserting that without additional built-in language
support, manual memory management is unduly difficult. Why so?
Because of this:
auto x = cast(MyClass) malloc(MyClass.classinfo.init.length);
x.__ctor( a, b, c ); // construct
...
x.__dtor();
free( cast(void*) x );
:)
You even forgot to register your object as a root in the GC, so if your
MyClass has any pointers to the GC your program will blow in your face.
If you plan to library support to ease this and avoid repetitive and
bug-prone work, you can ignore my complains...
I too think it would be great to add the necessary support to the
stdlib. In fact, since you have a great deal of expertise in the matter,
feel free to suggest API functions! They'd need to be approved by Sean
too because probably they belong to druntime.
Andrei