Suggest KSL return make infix fun
andrey-zakharov opened this issue · 3 comments
andrey-zakharov commented
fabmax commented
As far as I know infix functions only work between two arguments, so, witrh an infix return, you would need to write something before it to work:
kslFunctionBody.apply {
// this would not work because there is no argument left of return
`return` someValue
// this would work but is not better than the current non-infix variant
kslFunctionBody `return` someValue
}
Am I missing something?
andrey-zakharov commented
According to https://kotlinlang.org/docs/functions.html#infix-notation
Infix functions must meet the following requirements:
- They must be member functions or extension functions.
- They must have a single parameter.
- The parameter must not accept variable number of arguments and must have no default value.
So, as we have KslScopeBuilder.return
and one argument returnValue
it should works
fabmax commented
Yes you can declare it as an infix function, but it doesn't make a difference because you can't invoke it 'infix-style' as long as there is no argument left of it (like in my example above).
I mean I can make it infix, but it also won't make anything better (but it should not hurt either 😄)