[RFC] Add run_cleanup, do_with_cleanup

Martin Pool mbp at canonical.com
Thu Sep 24 09:07:06 BST 2009


2009/9/24 Andrew Bennetts <andrew.bennetts at canonical.com>:
> Martin Pool wrote:
>> 2009/9/24 Stephen J. Turnbull <stephen at xemacs.org>:
>>
>> > I believe Guido acknowledged not allowing the more compact notation in
>> > the first place to be excessive caution, but it's not impossible to
>> > distinguish exceptions raised by try_func from those raised by
>> > final_func.
>> >
>> > So what's the problem?  You want to do this without fixing all the
>> > broken try ... finally blocks?
>>
>> It's not _impossible_, we just don't want to add boilerplate to
>> everything that uses a try/finally block.  There are many more of them
>> than there are distinct types of cleanup to run.
>
> Especially when the boilerplate involved is just complex enough that it
> would be error-prone.
>
> e.g. your proposed boilerplate appears to be missing a raise in the except
> block... (unless you also suggest boilerplate in every final_func to start with
> saving sys.exc_info() and then finally reraise it!)

This is the place where Stephen's supposed to say something about Lisp
being a great improvement on many languages that came after it... ;-)

-- 
Martin <http://launchpad.net/~mbp/>



More information about the bazaar mailing list