Try blocks are trying
feepingcreature at gmail.com
Mon Oct 11 09:27:30 UTC 2021
On Monday, 11 October 2021 at 09:23:27 UTC, Imperatorn wrote:
> On Monday, 11 October 2021 at 09:21:48 UTC, FeepingCreature
>> On Monday, 11 October 2021 at 08:55:56 UTC, Imperatorn wrote:
>>> In that case you would just declare x outside and do the call
>>> in the try
>> Thus once again demonstrating that for a language that had a
>> major version change over it, D2 really doesn't care about
> I don't know about that. But it's pretty standard for try to
> introduce a scope.
The problem is if you want to use immutable types at all, this
forces you to either use awkward nested function idioms with
tuple returns for more than one variable, put the entire
remaining function body in the `try` block. It makes it
impossible to keep `try` small.
One possible solution would be a way to try/catch as an
auto x = frgl().tryCatch(Exception exc: return exc;);
But D has no precedent for statements embedded in expressions
like this, so it'd be a major language shift.
`export try` is the only feasible approach I can see offhand.
More information about the Digitalmars-d