Hi, I've noticed the `Either::catch` is no longer ...
# arrow
t
Hi, I've noticed the
Either::catch
is no longer suspend function and I'm curious what is the reasoning behind that change? I thought the reason was to denote it as a side effect, since throwing is a side effect. That I presume didn't change 😄
s
Hey @than_, You're correct that originally the idea was to explicitly denote it as a side-effect by marking it
suspend
. There are a couple of reasons or argumentations for removing
suspend
and just keeping it
inline
. We can consider pure
inline
functions co-pure since they can be used from pure contexts, but also from side-effecting ones. Since
inline
allows suspension to pass through, it can safely call suspension side-effects inside it's inlined body. Since
Either.catch
in its definition itself is
pure
there is no strong reason to keep it
suspend
, and by lifting that restriction we also ease the interopt with Java libraries for example. Performance-wise it's also beneficial to have it non-suspend
inline
over, suspend with a
suspend
lambda.
t
Makes sense 🙂 thanks