I don't think he invented it. For those who have an interest in it, a better alternative is, instead of declaring that you return "A", instead forget A and declare that you return "RuntimeException". Then, advise people to use:
throw sneakyThrows(new IOException()); instead of James's: return sneakyThrows(new IOException()); The point being of course that the "sneakyThrows" method never completes normally, so neither your "throw" nor your "return" statement actually "runs". The code blows up with an exception before that can happen. You do get the benefit of the compiler knowing this too, that code won't advance beyond this line, but in a way that's semantically closer. And you eliminate a generics parameter, that's always useful. On Sep 20, 1:17 am, Josh Berry <[email protected]> wrote: > Yeah, Specs has been the example that I've used to show people "literate > specifications." > > And, I realize there are some rather enjoyable "literate" programs in Java. > James Iry's wonderful chucking example is rather > fun.http://james-iry.blogspot.com/2010/08/on-removing-java-checked-except... > > On Sun, Sep 19, 2010 at 2:12 PM, Kevin Wright <[email protected]>wrote: > > > > > You should check out ScalaTest, or Cucumber in Ruby, or Spock in Groovy. I > > know there are similar frameworks in other languages - just can't remember > > the names right now! > > > For some reason, test frameworks seem to be a hotbed of innovation for all > > this literate DSL'y stuff > > > On 19 September 2010 18:58, Josh Berry <[email protected]> wrote: > > >> 2010/9/19 Cédric Beust ♔ <[email protected]> > > >>> I've found Java to be remarkably style impervious in the sense that I can > >>> read Java code using all kinds of different styles (different > >>> indentations, > >>> different brace placements, different namings for fields or variables, > >>> etc...) and not be bothered by it for more than a few seconds. > > >>> I can't say the same about C++ and it's probably too early to tell > >>> whether Scala has this nice quality too. > > >> I've found the biggest thing that I hate about Java nowdays is that I am > >> forced to organize my code around what Java wants, not around how I am > >> actually thinking about things. I grant that you can easily abuse packages > >> != directories, but I have found there is less value in that equality than > >> I > >> would have thought. > > >> Of course, I still have dreams of someday writing a "literate" program. :) > > >> -- > >> You received this message because you are subscribed to the Google Groups > >> "The Java Posse" group. > >> To post to this group, send email to [email protected]. > >> To unsubscribe from this group, send email to > >> [email protected]<javaposse%2bunsubscr...@googlegroups > >> .com> > >> . > >> For more options, visit this group at > >>http://groups.google.com/group/javaposse?hl=en. > > > -- > > Kevin Wright > > > mail / gtalk / msn : [email protected] > > pulse / skype: kev.lee.wright > > twitter: @thecoda > > > -- > > You received this message because you are subscribed to the Google Groups > > "The Java Posse" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]<javaposse%2bunsubscr...@googlegroups > > .com> > > . > > For more options, visit this group at > >http://groups.google.com/group/javaposse?hl=en. -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
