On Wednesday, April 03, 2013 11:27:38 Walter Bright wrote: > On 4/3/2013 11:08 AM, Jonathan M Davis wrote: > > (with most or all of the missing lines being due to stuff like catching > > Exception and asserting 0 in the catch block for making a function nothrow > > when you know that the code being called will never throw) > > Why not just mark them as nothrow? Let the compiler statically check it.
It's for cases where the compiler _can't_ check. For instance, if you had code like string foo(int i, int j) nothrow { try return format("%s: %s", i, j); catch(Exception e) assert(0, "format threw when it should have been impossible."); } the catch is necessary in order to mark the function as nothrow, because format _could_ throw. It's just that given the arguments, you know that it never will. - Jonathan M Davis