kool-engine/kool

Suggest KSL return make infix fun

andrey-zakharov opened this issue · 3 comments

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?

According to https://kotlinlang.org/docs/functions.html#infix-notation

Infix functions must meet the following requirements:

So, as we have KslScopeBuilder.return and one argument returnValue it should works

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 😄)