When using a language that has try/catch/finally, are D’s failure/success/exit scope statements still useful? D doesn’t seem to have finally which may explain why those statements are used in D. But with a language like C# is it useful? I am designing a language so if I see many pros I’ll add it in.
When using a language that has try/catch/finally, are D’s failure/success/exit scope statements still useful?
Share
scope(X)isn’t necessary in the same way thatforisn’t necessary provided you haveifandgoto.Here’s a paraphrased example from some code I’ve been writing today:
Contrast this to using try/catch:
The code has turned into spaghetti, spreading the error recovery all over the shop and forcing a level of indentation for every try block. The version using scope(X) is, in my opinion, significantly more readable and easier to understand.