A question about the posibility of raise-yield in Python
Ryan Kelly
ryan at rfk.id.au
Thu Jul 1 02:16:23 EDT 2010
On Wed, 2010-06-30 at 16:20 -0700, rurpy at yahoo.com wrote:
> On Jun 30, 10:48 am, John Nagle <na... at animats.com> wrote:
> > On 6/30/2010 12:13 AM, Дамјан Георгиевски wrote:
> >
> > >> A 'raise-yield' expression would break the flow of a program just like
> > >> an exception, going up the call stack until it would be handled, but
> > >> also like yield it would be possible to continue the flow of the
> > >> program from where it was raise-yield-ed.
> >
> > Bad idea. Continuing after an exception is generally troublesome.
> > This was discussed during the design phase of Ada, and rejected.
> > Since then, it's been accepted that continuing after an exception
> > is a terrible idea. The stack has already been unwound, for example.
> >
> > What you want, in in the situation you describe, is an optional
> > callback, to be called in case of a fixable problem. Then the
> > caller gets control, but without stack unwinding.
I've tried my hand at implementing the "condition/handler/restart"
paradigm of common lisp, which is very similar to what you describe.
You might find it useful:
http://pypi.python.org/pypi/withrestart/
Cheers,
Ryan
--
Ryan Kelly
http://www.rfk.id.au | This message is digitally signed. Please visit
ryan at rfk.id.au | http://www.rfk.id.au/ramblings/gpg/ for details
More information about the Python-list
mailing list