Something like: `fun ValidateTextField(foo: Bar, @...
# compose
r
Something like:
fun ValidateTextField(foo: Bar, @ParamsOf<TextField> p)
e
There've been also various ideas floating in Kotlin on how this might be solved in general case. One I'm personally a fan of: https://youtrack.jetbrains.com/issue/KT-15471
👍 11
c
It would be nice to also be able to turn a functions parameters into a
dataargs
capable type using some operator such as
ParamsOf
as alluded to by Romain. This fits nicely with
dataargs
allowing
CustomButton
, from the proposal, to be written without
Button
having to be modified ahead of time.
e
It raises the problem of separate compilation, then. It may or may not be important, but a factor to consider.
Hm... just a thought. If a target function opts-in into reuse of its parameter lists, then it may be made to work with separate compilation.
c
Good point. We would need a way to have separate compilations be able to share the class implied by
ParamsOf
. For native this should be easy, such as using a COMDEF record or equivalent, but for the JVM is would be more challenging.
e
One solution is to always generate a hidden “params class” for every composable function and always pass params though this class, which would make the process of sharing parameters completely transparent for end-users, yet it will also always add some overhead.
c
That was my intent if we implement it as part of
@Composable
. The number of hidden classes explode, however, if it is general language feature.