On Saturday, 27 September 2014 at 10:01:05 UTC, Ola Fosheim Grøstad wrote:
On Friday, 26 September 2014 at 21:19:29 UTC, Walter Bright wrote:
I would. The whole point of destructors is to automatically clean up resources when the object goes away, which was (later) dubbed RAII.

Yeah, but RAII takes it to the extreme where you create dummy classes that only consist of constructors/destructors so that the stack unwinding does all cleanup/closing/freeing without any try/catch.


This is not necessary in D as we have scope statements.

Before C++ templates that looked verbose and ugly syntactically, and it is still tedious if you only use the specific resource in one location. "scope(exit)" is often more transparent IMO.

I guess this is matter of style and various tradeoff. A very common operation to rollback probably deserve its own RAII struct. An uncommon one is better served with scope.

Reply via email to