On 05/16/2012 11:17 PM, Jonathan M Davis wrote:
On Wednesday, May 16, 2012 23:05:07 Timon Gehr wrote:
On 05/16/2012 08:59 AM, Walter Bright wrote:
On 5/15/2012 8:54 PM, Mehrdad wrote:
Is there any way for me to use scope(exit) (or perhaps a destructor,
like RAII)
to mean, "Execute this block of code for me when the block is exited,
will ya?",
*without* introducing dependencies on exception handling?
Make sure the guarded code is 'nothrow', and it should work.
Doesn't that imply that 'in'-contract checking might leave the program
in an invalid state?
Well, according to Walter, there is no guarantee that _any_ cleanup will be
done when an Error is thrown (including AssertError), so yes, there's the
possibility that an in contract could leave the program in an invalid state if
it fails.
The issue is not relevant for failing contracts. 'in' contracts might
pass even if some assertion errors were thrown during their evaluation.
However, with the current implementation, as I understand it, it
_is_ guaranteed that cleanup will be done for Errors. But if the try and
finally blocks are indeed removed, then that would seem to indicate that
there's a case where there _won't_ be any cleaup for Errors in spite of the
fact that Don (and and Dan?) tried to make sure that it _was_ guaranteed. But
if the cleanup doesn't happen, it would still be within what Walter considers
to be guarantee for Errors as far as the spec goes.
- Jonathan M Davis
Exactly, this is somewhat bothersome.