3 ms·
>Is the D scope + unrecoverable error different from Go's "defer" and "panic"? D's scope guard is similar to "defer", but it has three forms: "scope(exit)", "s
by edmccard 13y ago
>Is the D scope + unrecoverable error different from Go's "defer" and "panic"?
D's scope guard is similar to "defer", but it has three forms: "scope(exit)", "scope(failure)", and "scope(success)". So instead of a deferred function that tests "if r := recover(); r != nil {...}" you just do "scope(failure) {...}"
D's unrecoverable error is just a matter of having an exception hierarchy where "Exception" and "Error" are separate subclasses of "Throwable", and by convention you prefer not to write "catch (Throwable t)" or "catch (Error e)".