On Sunday, 19 February 2012 at 01:29:40 UTC, Nick Sabalausky
wrote:
Another one for the file of "Crazy shit Andrei says" ;)
From experience, I (and clearly many others here) find a
sparse, flat exception hierarchy to be problematic and
limiting. But even with a rich detailed exception hierarchy,
those (ie, Andrei) who want to limit themselves to catching
course-grained exceptions can do so, thanks to the nature of
subtyping. So why are we even discussing this?
How about we revisit ancient design decisions which once held
true... but no longer is the case due to our "god-language" being
more expressive?
In my experience an "exception hierarchy" is never good enough,
it suffers from the same problems as most frameworks also do...
they simplify/destroy too much info of from the original error.
ex why don't we throw a closure? Of course we could go crazy with
mixins and CTFE,CTTI,RTTI aswell... imho the goal should not be
to do as good as java, the goal is progress! Java should copy our
design if anything... we could have a very rich exception
structure... without the need for a hierarchy.
try(name) // try extended to support full closure syntax
{
DIR* dir = opendir(toStringz(name));
if(dir==0 && errno==ENOTDIR)
throw; // throws the entire try block as a closure
}