On 06/11/2011 12:34 PM, Rémi Forax wrote:
On 06/11/2011 02:50 AM, Charles Oliver Nutter wrote:
On Fri, Jun 10, 2011 at 7:36 PM, John Rose<[email protected]>
wrote:
Yes. Put the postCall wrapper *outside* the postException
wrapper. That way the postCall guy won't participate in the special
exception processing.
If postException catches and discards the exception, then it will
return normally to the postCall wrapper.
If you want the postCall wrapper to distinguish the caught-exception
case from the normal-return case, you may have to contrive a boolean
flag variable, for them to share, so the inner wrapper can tell the
outer wrapper what happened.
I have gone from depression to elation. To avoid this happening again,
I'm going to spend part of the weekend wiring up all such cases in
JRuby and make damn sure I've got every angle covered.
Thanks for the help, John!
- Charlie
There is two way to implement try/finally,
one is to store the exception in the catch, let the catch fall through
the postCall
and rethrow the exception after. The other is to catch the exception,
call the postCall
and retrow the exception (you group postCall and rethrow with a fold
(here you can even use filterReturnValue)) and call postCall after the
tryCatch, again
by folding the catchException and postCall. In that case, postCall
appear twice,
this is the strategy implemented by javac or eclipse to implement a
try/finally.
Anyway, this mean I (or Charlie or anyone who want) have to write new
sample
for the cookbook.
cookbook updated :)
http://code.google.com/p/jsr292-cookbook/
I've also added code for AOP like before/after logic.
before* takes a method handle (that returns void) that will be called
before the target method handle.
after calls the method handle after, and put the result value of the
target as first argument before
the arguments of the call.
Rémi
Rémi
* in fact, before is equivalent to foldArgument() with a void combiner,
I've just added it for completion
--
You received this message because you are subscribed to the Google Groups "JVM
Languages" 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/jvm-languages?hl=en.