https://kotlinlang.org logo
Title
r

rocketraman

12/06/2018, 12:18 AM
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

gildor

12/06/2018, 12:21 AM
Probably only runBlocking, because such function is completely syncronous
Or write own asyncronous version
r

rocketraman

12/06/2018, 12:21 AM
Ok, that's what I thought -- do you think these kinds of functions will get coroutines-friendly versions in the future?
g

gildor

12/06/2018, 1:23 AM
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

rocketraman

12/06/2018, 2:03 PM
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.