Has there ever been discussion about an annotation...
# language-evolution
e
Has there ever been discussion about an annotation to disallow trailing lambdas for a given function? For example
Copy code
fun handleClicks(
  onClick: () -> Unit,
  onLongClick: () -> Unit
)
loses context when called like
Copy code
handleClicks(
  onClick = {...}
) {
  ...
}
8
💡 5
w
Related, I'd definitely use an annotation that strongly suggests that a function should be called only using named parameters
p
Ugly solution:
Copy code
fun handleClicks(
  onClick: () -> Unit,
  onLongClick: () -> Unit,
  noLambda: Nothing? = null
)
m
e
🌟 4
r
Also, instead of
noLambda: Nothing? = null
, I would recommend
vararg noLambda: Nothing
, It reduces the potential confusion of something like:
Copy code
handleClicks(
    { ... },
    { ... },
    someFunctionThatReturnsNull(),
)
Though it's probably not a big deal.
👍 1