Exception programming difficult

Dmitry Olshansky dmitry.olsh at gmail.com
Mon Aug 13 08:32:38 PDT 2012


On 12-Aug-12 07:02, Marco Leise wrote:
> I just got a bit frustrated and wanted to say that I like working with Exceptions in Java a lot more.
That has to do first but not foremost with the declaration:
>
> ---Java->>
>
> class MyException extends Exception {
>    public MyException(String msg) {
>      super(msg);
>    }
>    public MyException(String msg, Throwable next) {
>      super(msg, next)
>    }
> }
>
> <<-Java---

I think the true cryptonite that melts "checked exceptions" to a pile of 
green goo is templated code:

So (*yawn*) tell what kind of exception specification the following 
function should have:

auto joiner(RoR, Separator)(RoR r, Separator sep);

How would you guarantee upfront what kind of exceptions it can throw is 
beyond me. It all depends on code that you can't reach or know by the 
very definition of template.

Back to Java: what is I find strange is the lack of sensible tools to do 
transactional or exception safe code within the language. No RAII 
objects or just at least any kludge to reliably register 
cleanup/rollback, only "good" old try/finally.

-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list