are there any plans in the future to allow overloading methods based on whether they're suspending or not?
Copy code
fun blah() { ... }
suspend fun blah() { ... }
now if I'm in a coroutineContext and call blah, it calls the suspending one and if I'm not in a coroutineContext or in Java-land, it calls the non-suspending one
s
stojan
11/02/2022, 11:01 AM
you can call your non-suspend version from suspend context....
if you can define a function as non-suspend you should do that, why would you mark it suspend if you don't need to?
g
gildor
11/02/2022, 12:38 PM
It would cause ambiguous call resolution from suspend context
gildor
11/02/2022, 12:38 PM
So I don't think that it's possible
gildor
11/02/2022, 12:40 PM
Also semantically those functions are quite different (first is blocking or launches background work and do not allow to wait for it)
Usually for java I would have something like:
fun blahFuture(): CompletableFuture