That makes it even easier for people uninterested in the exception to
suppress it as the minimum effort to make their code compile.  Someone would
then have to systematically go back later and make sure each exception is
handled properly.  It would be better if the minimum effort was something
like

void myMethod() throws private IOException {
  f.open();
  etc();
}

which would compile to

void myMethod() {
  try {
    f.open();
    etc();
  }
  catch (IOException e) {
    throw new RuntimeException(e);
  }
}

On Thu, Sep 23, 2010 at 2:12 AM, Josh McDonald <j...@joshmcdonald.info>wrote:

> Hey guys, I'm not weighing in on checked v unchecked, just a syntax sugar
> idea!
>
> We've got two ifs:
>
> if (foo)
>   bar();
>
> and
>
> if (foo) {
>   bar();
> }
>
> So why not introduce a cut-down syntax for common exceptions? Something
> like this:
>
> try file=File.open(...) catch(SomeException se, OtherException oe);
>
> Which would be expanded out by the compiler to this:
>
> SomeException se = null;
> OtherException oe = null;
>
> try {
>   file = File.open(...);
> } catch (SomeException e) {
>  se = e;
> } catch (OtherException e) {
>   oe = e;
> }
>
> And you can check the contents of the exception or not at your leisure.
>
> Thoughts?
>
> --
> "Therefore, send not to know For whom the bell tolls. It tolls for thee."
>
> Josh 'G-Funk' McDonald
>    -  j...@joshmcdonald.info
>    -  http://twitter.com/sophistifunk
>    -  http://flex.joshmcdonald.info/
>
>  --
> You received this message because you are subscribed to the Google Groups
> "The Java Posse" group.
> To post to this group, send email to javapo...@googlegroups.com.
> To unsubscribe from this group, send email to
> javaposse+unsubscr...@googlegroups.com<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 javapo...@googlegroups.com.
To unsubscribe from this group, send email to 
javaposse+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to