Try blocks are trying

jfondren julian.fondren at
Sun Oct 10 16:31:55 UTC 2021

On Sunday, 10 October 2021 at 16:12:31 UTC, Carl Sturtivant wrote:
> Design error?

A block not introducing a scope is weird, and my first reaction 
to the {{ }} workaround was disgust. That's with version and 
static foreach blocks where not introducing a scope has very 
clear benefits. Try/catch meanwhile is a familiar construct and 
people are already used to working around issues like this.

typeof(frgl()) x;
try {
     x = frgl;
} catch (Exception e) { }

I'd consider also if you can use std.exception.ifThrown or a 
scope statement instead:

auto x = frgl().ifThrown(typeof(frgl()).init);

More information about the Digitalmars-d mailing list