What's the best way to adapt lambdas that are not ...
# coroutines
r
What's the best way to adapt lambdas that are not inline and are not suspendable? e.g.
public inline fun CharSequence.replace(regex: Regex, noinline transform: (MatchResult) -> CharSequence): String
from the stdlib
g
Probably only runBlocking, because such function is completely syncronous
Or write own asyncronous version
r
Ok, that's what I thought -- do you think these kinds of functions will get coroutines-friendly versions in the future?
g
I don’t think that such functions will be updated with coroutines support. This would backward incompatible change at least for JVM interop Also not sure that it worth to add async Regexp to stdlib, I just not sure that it would be really widely used, maybe someone could just write 3rd party library for that
But maybe some other functions could get coroutines support, but I don’t have particular candidates
r
I think I'm going to take a 2-pass approach -- find the matches with regex first, do the suspending call on each match, saving the results, and then do the regex call with transform.