I've been using context parameters a lot, and one ...
# language-evolution
h
I've been using context parameters a lot, and one thing I really miss is the ability to pass
KFunctions
in places where lambdas with context are expected. For example
Copy code
class Server

data class Foo(val action: context(Server) (Int) -> Unit)

context(_: Server)
fun doSomething(int: Int) { ... }

// val foo = Foo(::doSomething) This currently doesn't work
val foo = Foo { doSomething(it) }
I would really like to be able to pass
::doSomething
into
Foo,
but it doesn't work currently. I know context parameters are experimental, is this something expected to be fixed/added in the future? There's a YouTrack issue for this, but I don't see any timeline for it or if it's even expected to change.
y
I think the plan is that
::doSomething
eagerly grabs the available contexts (this behaviour is shared with Scala I believe). Maybe that'll change though, so that it grabs as many contexts as it can, but leaves the rest intact
👍 1
p
This is something planned for future at some point, but • As mentioned above, it doesn't solve your use-case, as contexts are designed to be captured • Not in immediate plans because of being blocked by internal technical problems in several places. It's even possible that we would first stabilise it as is and then add references as a separate feature, maybe also refining the use case of references to functions with both extension and dispatch receiver, which is also not supported yet. If you have an example, where lack of support make something impossible, or significantly less convinient, please leave a comment in mentioned issue.