Now that exceptions are in the language, is there any performance benefit to using them to escape from a long call stack?
In other languages this is a technique that is used to unwind all of the accumulated stack frames in one operation.
Now that exceptions are in the language, is there any performance benefit to using them to escape from a long call stack?
In other languages this is a technique that is used to unwind all of the accumulated stack frames in one operation.
I assume you’re comparing it against an Either
/EitherT
style short-circuiting?
I do expect exception throwing to outperform that. However, I think it’s important to clarify a few points/caveats:
Update
. Otherwise the exception will roll them back whereas Either
will not roll them back.Update
. I’d think twice about moving things into Update
just to get a performance boost.>>=
on Either
, you can probably gain something. However, most code does something interesting between binds and then the performance advantage can easily become insignificant.