The "around" pattern
Charles Oliver Nutter
headius at headius.com
Fri Jul 3 16:08:55 PDT 2009
John, I had a couple thoughts on the "around" adapter we were talking
about for e.g. synchronization.
* Around would specify a before, body, and after
* Guaranteed execution of the "after" would be specified by a flag?
You may not want to run it if there's an exception.
* Synchronization would be a special case of the "around" but I think
there may need to be a special method to create it, something like:
synchronizeAround(target, selector)
where target is the body of the synchronized section and selector
receives target's arguments and returns an object to sync against.
The general case of around would be simpler to use for "finally" than
the catchException adapter, since you could just have this:
around(target, noop, finallyBlock, true)
Where the args are "body, before, after, finallyOrNot?"
I've been trying to figure out a clean way to do a finally with
current adapters, but it's a little cumbersome. Suggestions?
- Charlie
More information about the mlvm-dev
mailing list