Something like the "with statement" in Koka could ...
# language-proposals
j
Something like the "with statement" in Koka could drastically reduce the number of nested curly braces in some situations. https://koka-lang.github.io/koka/doc/book.html#sec-with Something like this:
Copy code
fun example() {
    wrapped with with(SomeDSL)
    dslCall()
}
desugars to:
Copy code
fun example() {
    with(SomeDsl) { 
        dslCall()
    }
}
The big opportunity I see here is that "middleware"-ish functions could be much easier to use. It might be a bit much, though. Goodness knows we have plenty of syntax already.
i
We're considering a similar feature in the context receivers proposal: https://github.com/Kotlin/KEEP/blob/master/proposals/context-receivers.md#scope-properties
j
Ah ha! I'm not surprised it's made it's way into a KEEP already, I just didn't know what it would be called. Thanks!