newbie problem with nothrow

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Nov 1 09:24:27 PDT 2016


On Tuesday, November 01, 2016 12:19:11 Steven Schveighoffer via Digitalmars-
d-learn wrote:
> On 11/1/16 11:54 AM, Jonathan M Davis via Digitalmars-d-learn wrote:
> > On Tuesday, November 01, 2016 10:57:38 Steven Schveighoffer via
> >> Is there not some assumeNoThrow wrapper somewhere?
> >
> > Someone added assemWontThrow to std.exception semi-recently, but I'd be
> > very surprised if it didn't incur performance overhead such that I'd
> > just as soon use an explicit try-catch and be done with it.
>
> The function I'm imagining shouldn't add any overhead...

assumeWontThrow uses lazy to do what it does (and I'm not sure that there's
any other way to do it other than string mixins), and as I understand it,
lazy isn't exactly efficient. Given that it always calls the resulting
delegate though, the optimizer may be able to remove the extra cost.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list