Conor Walsh writes:
>
> Maybe I'm out of my depth, pun not intended, but I was under the impression
> that thrown exceptions have to unwind the stack anyway. Is there some way
> exceptions are usually implemented that doesn't cost as much as unwinding
> the stack one level at a time? It seems like 3-or-300 does matter, in that
> you have to check for and possibly call some number of destructors or risk
> leaking all over the place.

Also (relative to Ben Tilly's mail), it is possible to use techniques like 
maintaining a table of current handlers and using dynamic jumps in order to 
bypass uninteresting stack frames and hop directly to the "finally" code that 
calls destructors & such, and to the handler for the exception being raised.

Of course, if a given implementation presumes "Exceptions are always errors", 
it may walk the stack anyway and build up a whole data structure that describes 
where the exception took place.  That would indeed be fairly slow to say the 
least.  But they don't have to be like that.

Even still, as Ben said, a "slow" exception mechanism can nonetheless be faster 
than the overhead of a number of test/branch cases.

                                          

_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to