Hacker Newsnew | past | comments | ask | show | jobs | submit | rogerkeays's commentslogin

Andrews PW, Thomson JA Jr. The bright side of being blue: depression as an adaptation for analyzing complex problems. Psychol Rev. 2009 Jul

https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2734449/


This language looks really cool. Thanks for sharing.


You can also rethrow checked exceptions as runtime exceptions by exploiting type erasure:

    public static RuntimeException unchecked(Exception e) {
        Exceptions.<RuntimeException>throw_checked(e); 
        return null; 
    }
    private static <E extends Exception> void throw_checked(Exception e) throws E {
        throw (E) e;
    }
then you can do this:

    try { ...
    } catch (IOException e) {
        throw unchecked(e);
    }
And the original exception is thrown without being wrapped. It's as though you had `throws IOException` on your method signature.

This is from my original solution to the problem: https://github.com/rogerkeays/jamaica-core/blob/0cc98b114998...


There's one big problem with this approach. You can't catch checked exception if the try-block does not throw it (according to compiler). That's compiler error.

So yes, you can throw IOException masking it to RuntimeException, however you can't catch it later without another gimmicks like catching Exception and checking if it's IOException (and even that check causes linter warnings in Idea, so now you need to suppress those warnings...).

Throwing and catching UncheckedIOException does not have this problem.


Good point. Actually the plugin didn't handle this case either (fixed now). Thanks for the feedback.


... not sure if serious or not



I'm completely serious in the sense that you could do that and really would in some situations.

You might do it because you want to factor the handling of the different result cases out to another function.


You don't think it would limit the independent use of f()?


No? Surely if f() takes a full result (including error condition) it's because there's something it wants to do with that?


I put Java's popularity down to good support for Corporate-Oriented Programming ;)


Coproporate-Oriented would be a better description


You still get warnings about checked exceptions from this plugin, so it's not entirely flying blind.


I think this project shows how trivial it is to convert checked exception errors to compiler warnings.

https://github.com/rogerkeays/unchecked/blob/f22c8cde3557de0...

No need to change the type hierarchy. Just make it a compiler option.


Good point...


Ha, yeh. At first I had the command line examples first, but everyone was going on and on about maven and stuff, so I figured that's what the audience wants.

[EDIT] I moved the command line stuff back to the top of the README. XML makes my eyes bleed too...


The "what to do" and "tests" sections of this article is spot on! As for the sociopath/psychopath distinction, I think both terms refer to people with a Cluster B personality disorder. Since this is such a mouthful, I just call them predators, or if I don't want to scare people: vogons.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: