scope(exit) with expected library
Paul Backus
snarwin at gmail.com
Wed Aug 25 15:02:39 UTC 2021
On Wednesday, 25 August 2021 at 14:42:07 UTC, Steven
Schveighoffer wrote:
>
> I think it's possible to work with some mechanics that aren't
> necessarily desirable. Something like:
>
> ```d
> ErrorHandler error = registerErrorHandler;
> error.onFailure({writeln("division failed");});
> error.onSuccess({writeln("division succeeded");});
>
> ...
> ```
This is kind of like what Common Lisp has with its condition
system. One downside of this approach in D is that it would not
work well with static analysis features like `@safe`, `nothrow`,
etc., since the handlers are not known until runtime. But it does
offer a lot more flexibility than traditional exceptions.
More information about the Digitalmars-d-learn
mailing list