Am Tue, 26 Aug 2014 20:59:57 +0000 schrieb "Robert burner Schadek" <rburn...@gmail.com>:
> nothrow I get, but nothrow in dtors is a much wider topic (please > open a new thread if you want to discuss this) and see my example > to hack around it. You are right. > but no nogc should be no problem as long as you use a Logger that > doesn't allocate for logging, as for example FileLogger. And even > than, what is the problem with no nogc logging in dtors? > > -------------- > class Foo { > ~this() { > try { > log("Foo"); // log to file > } catch(Exception e) {} > } > } > -------------- As far as I know, exactly this is not possible with the current GC implementation. The exception you catch there has just been allocated somewhere deeper in the log function. But all GC allocations in a GC invoked dtor cause MemoryErrors and program abortion/crashes. :( In a perfect world I'd imagine you can set up a fallback logger. So if the disk is full an exception is thrown by e.g. std.stdio.File, which is passed as an error level log message to the fallback logger, which might write to stderr: "ERROR: Could not write the following message to logXYZ: <message> The reason was: Disk full" -- Marco