Suggestion: Syntactic sugar for Exception handling in D2

Ulrik Mikaelsson ulrik.mikaelsson at gmail.com
Tue Jun 23 16:36:26 PDT 2009


> I suggest looking at D's scope guard statements, which replace most uses 
> of try statements.
While scope guards is absolutely the right solution to resource handling and transactions, I don't see how to use it for some other common uses of exceptions where you need a reference to the exception that was thrown such as error-logging, and exception wrapping.

As I've written in a few other places in the thread now, it's not about lacking other solutions to the problem. Scope guards and the existing exception-handling do cover all possible cases. It's neither about fear of wearing out my bracket-keys. It's merely about readability, and slightly shifting how the language affect how developers think about exception handling, trying to make exception-cases a natural but separate part of each method (1). I think I'm already seeing that same reasoing for a few other features in D, such as the contract and unittest-constructs in the language. But those values are highly subjective, and how the language affect the mindset is also very difficult to assess and value without working with it for a while.

1)  I've completely abandoned the idea for other blocks than methods. It was a bad idea from start, just ambiguous and doesn't make sense at all.



More information about the Digitalmars-d mailing list