Safety/purity and assert/enforce error messages
Joseph Rushton Wakeling
joseph.wakeling at webdrake.net
Thu Sep 12 13:17:30 PDT 2013
On 12/09/13 22:07, Jonathan M Davis wrote:
> format can't be nothrow, because it throws when you screw up the format
> specifiers. You have to wrap it in a try-catch block and assert(0) in the catch
> block if you want to put it in a nothrow function. std.datetime does this in
> at least a few places.
The annoyance of this is that it means that any otherwise @safe pure nothrow
function that has an assert() in it can be blocked from being nothrow if it
needs a formatted string for the assert failure message.
Note that this restriction still applies even if the code is being compiled with
-release and the assertion therefore stripped out.
Or am I missing a trick as to how to deal with assert() and enforce() ... ? :-)
More information about the Digitalmars-d-learn
mailing list