[e-lang] Notes from latest Joe-E meeting

David Hopwood david.hopwood at industrial-designers.co.uk
Mon Apr 30 20:41:37 EDT 2007


I wrote:
[...]
> Here is a more complete implementation that provides 'try/catch/finally' as well
> as just 'try/finally', fixes the Java (and E) design flaw described at
> <http://www.eros-os.org/pipermail/e-lang/2006-July/011371.html>, and provides
> versions for use when the whole construct is not expected to throw a checked
> exception. [...]

>     public static void tryCatchFinallyThrowsChecked(
>                        Thunk tryThunk, Catch handler, Thunk finallyThunk)
>                        throws Exception {

On second thoughts, this method (and the Catch class) is unnecessary.
A try/catch/finally can be written as:

  JoeE.tryFinallyThrowsChecked(new Thunk() { public void run() { try {
      ... X ...
  } catch (FooException e) {
      ... Y(e) ...
  }}}, new Thunk() { public void run() {
      ... Z ...
  }});

which is arguably better than:

  JoeE.tryFinallyThrowsChecked(new Thunk() { public void run() {
      ... X ...
  }}, new Catch() { public void handle(Exception e) {
      if (e instanceof FooException) {
          ... Y((FooException) e) ...
      } else { throw e; }
  }}, new Thunk() { public void run() {
      ... Z ...
  }});


(Come back, C preprocessor... all is forgiven. Well, maybe not.)

-- 
David Hopwood <david.hopwood at industrial-designers.co.uk> (note new address)



More information about the e-lang mailing list