simon.vergauwen
08/16/2021, 6:41 PMelizarov
08/19/2021, 10:44 AMlaunch { helloWorld() }
looks just as nice. What’s the point on insiting on using ::helloWorld
here?simon.vergauwen
08/19/2021, 3:16 PM::helloWorld
here was just a small example. It’s something I come across from time to time, when working receivers. Not only specific to CoroutineScope
, but also with other DSLs or builders that work with receivers to expose specialised DSL syntax. A better example might be parZip
from Arrow Fx, where users would like method references. i.e. to constructors of data classes but you cannot due to the CoroutineScope
receiver.
I’ve noticed in the past that some Arrow users go out of there way to redefine methods without the receivers, to be able to pass method references but I’ve never gone that far. Like you suggest I prefer using helloWorld()
in those cases.
I was wondering if this was already discussed before since the Kotlin compiler already support similar mechanisms such as passing () -> A
where suspend () -> A
is expected and similarly () -> A
also fits into R.() -> A
.elizarov
08/19/2021, 3:19 PMR.() -> A
to () -> A
.