[Christian Tismer] > Does anybody know of a useful example where continuations > are really needed? [Moshe Zadka] > Well, it may be a bit unpythonic (for several reasons), but restartable > exceptions AFAICS cannot be implemented by generators or coroutines. > Restartable exceptions are not always appropriate, but tend to be > a pain to simulate when they are needed. [Christian Tismer] > How would restartable exceptions work? Like so? > > try: # here, a continuation is saved > pass # some operations which may fail, > # raising something that inherits from RestartableException > > except RestartableException: > pass # repair the condition > sys.try_again() # go back to the try statement I imagined something like try: raise RestartableException, continuation.current_continuation() except RestartableException, ex: # correct the problem ex.saved_continuation() IOW, just put the continuation in the exception object. I don't think you can use generators/coroutines to simulate something like this -- Moshe Zadka <moshez@math.huji.ac.il> -- 95855124 http://advogato.org/person/moshez
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4