try/catch idiom in std.datetime

Jonathan M Davis jmdavisProg at gmx.com
Mon Nov 18 01:13:30 PST 2013


On Monday, November 18, 2013 10:09:35 Jacob Carlborg wrote:
> On 2013-11-18 09:14, Andrei Alexandrescu wrote:
> > I'm also concerned about generated code size and overall efficiency. It
> > looks like the assert(0) insertions are there simply to validate the
> > design (they only fail if Phobos has an internal error), so there should
> > be some means to remove them in release builds. We don't have such a
> > possibility at the moment.
> 
> Asserts are supposed to be removed in release builds.

The aren't if the condition is statically known to be false, as is the case 
when you use a try-catch block to catch Exception and then assert within the 
catch block in order to make the function be able to be nothrow.

> There's also the
> "debug" statement that can be used. Although it won't remove the try-catch.

It also won't run unless you compile with -debug, which I expect very, very 
few people do.

- Jonathan M Davis


More information about the Digitalmars-d mailing list