Hi all, what’s a good upper limit for # of paramet...
# compose
t
Hi all, what’s a good upper limit for # of parameters for a Composable (incl ones with default values)?
z
640K parameters ought to be enough for anyone
🙃 2
😂 6
k
OutlinedTextFieldLayout
has 24
1
👀 1
t
oh 24! trying to find anything within material/foundation that has more than that…at the very least, maybe 24 is a good upper limit esp if some params are optional… 💭
just for context, trying to come up with a good rule of thumb for customizing detekt/static analysis rules
j
Limits are meant to be broken.
😂 2
😅 4
e
there's a limit of 255 parameter slots on JVM method signatures
r
Note that when using named parameters, Kotlin will add an extra parameter per 32 parameters (+ an extra Object if I remember correctly)
👀 1
z
And Compose adds its own parameters too
r
So you can’t have 255 params in the original function declaration
👌 1
Yeah good point
e
when using named parameters when using default parameters, yeah there's a bitmap int for each set of 32 parameters, and a marker parameter to prevent collisions with other overloads
Compose adds 2 hidden parameters? I think that brings us to 244 usable parameters, in theory (half that if they're
long
or
double
because those take up two slots)