mark florisson, 05.07.2012 20:47: > On 3 July 2012 20:15, Robert Bradshaw wrote: >> On Tue, Jul 3, 2012 at 11:43 AM, Dag Sverre Seljebotn >>> Though I guess one might want to try to pull out the try-catch to at least >>> only one per code line rather than one per SimpleCallNode. >> >> Or even higher, if possible. It's still a lot. > > Why would you have to do that? Can't you just insert a try/catch per > try/except or try/finally block, or if absent, the function body. That > will still work with the way temporaries are cleaned up. (It should > also be implemented for parallel/prange sections).
My first reaction was, "sure, smart idea". It certainly sounds like a good idea to unify the exception handling between C++ and Python into the same syntactic structures. But does it allow to handle different declarations for multiple C++ functions that get called? E.g. "except +" for one and "except +MemoryError" for another, but both called in the same try-whatever block? That would just lead to nested try-except blocks, I guess, thus making the outer exception clauses mostly a fallback for exceptions that users forgot to declare or couldn't properly handle for some reason. I think it's worth a try to see if it works. BTW, is there a reason we can't allow users to declare C++ exceptions in their .pxd files, and then support catching them in Python try-except syntax? Just verbatimly translating them to the C++ structures, based on the type of the exception that gets caught? (Although, given the discussion so far, maybe try-finally is more important than try-catch, and the former can't know when it needs to be mapped into C++ code and when not ...) Stefan _______________________________________________ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel