Hello, is there something like IntFlow instead of ...
# coroutines
a
Hello, is there something like IntFlow instead of Flow<Int> to avoid auto-boxing?
🚫 5
j
The primary inhibitor here is not the kotlinx.coroutines library and the lack of specialization (which would be a pretty ridiculous effort because of the surface area of
Flow
and its operators as well as breaking the ability to reuse custom operators and pipelines), but of the language choices as to how
suspend
functions are compiled. Fundamentally, the underlying method will return
Object
which is a union of
T | COROUTINE_SUSPENDED
that will force boxing if the suspend function completes synchronously, or it will invoke
Continuation<T>
which is an interface that forces boxing if the suspend function completes asynchronously. So even an attempt to build such a thing would be impossible without overhauling coroutine support in the language first, and I don't think that's something the team would want to pursue.
a
Oh, thanks, I got it.