Am Thu, 16 Aug 2012 15:11:41 +0200
schrieb "Manipulator" <vo...@kth.se>:

> I had times when I missed the Java-style Exception handling.
> 
> First time I just the D sockets exceptions was thrown during 
> runtime. The Library Reference didn't tell my anything about 
> exceptions neither did the compiler.
> This could've been avoided with documentation stating which 
> exceptions can be thrown or if the compiler had warned me about 
> it.
> I see checked exception handling as mean to remind programmers to 
> handle certain errors. This is not done in D.
> 
> I've also cursed the Java-style many times. For example:
> interface MyInterface {
>   public void method throws IOException();
> }
> 
> class MyClass implements MyInterface {
>   public void method throws IOException() {
>    //Doesn't need throw IOException!!!!
>   }
> }
> 
> I liked the idea when the compiler is able to warn me about 
> unhandled exceptions.
> 

I've been thinking shortly about this. Can we narrow down the thrown 
exceptions? Can an interface declare that it's descendants may throw 
IOExceptions, but an implementation may practically be nothrow?
This could have the special effect that in cases where MyClass is used as the 
declared type, no exception handling would have to be done, while that would 
still be the case for MyInterface. If that's possible it would be another small 
improvement over Java.

-- 
Marco

Reply via email to