On Saturday, 24 January 2015 at 23:28:35 UTC, Jerry Morrison
wrote:
On Saturday, 24 January 2015 at 15:04:47 UTC, Ola Fosheim
Grøstad wrote:
If the classes are written for RAII then the destructors have
to be called in reverse order of the constructors. IIRC D does
not guarantee this when you use the GC.
So to do it right there is a lot of GC overhead.
Yes, but the usability question is what do programmers expect?
How much do they assume before turning to the docs?
Unfortunately, I think D is now entrenched in Java/C#ish
expectations. Which is no good, since the main advantage D can
have over those languages is to restrict the language semantics
to a level where D has an inherent performance (timeliness)
advantage.
My expectations from a GC in a system level programming language
would be to give max priority to fast collection at the expense
of features (lean and mean).
It's a big stretch to expect LIFO behavior from garbage
collection. It's not a stretch to expect logging to work.
What does logging in a destructor tell you? The destructor might
not execute until the program terminates.
You might not expect LIFO from the GC, but can you trust library
authors to ensure that it does assume LIFO when manual memory
management becomes commonplace?
D needs to define what it means by "safe" and "convenient". It is
currently very much up in there air when it applies and when it
does not.