Gilles Barbier
10/14/2024, 10:54 PMcontext(A, B)
, it would be convenient to have mutliple elements in with: with(a, b) { ... }
Fergus Hewson
10/14/2024, 10:59 PMChris Lee
10/14/2024, 11:54 PMCLOVIS
10/15/2024, 7:25 AMthis
, even right now:
class Foo {
fun showFoo() {
println(this)
}
inner class Bar {
fun showBar() {
println(this)
}
fun exec() {
with(Baz()) {
showFoo()
showBar()
showBaz()
}
}
}
class Baz {
fun showBaz() {
println(this)
}
}
}
Foo().Bar().exec()
Fergus Hewson
10/15/2024, 7:14 PMJokubas Alekna
10/25/2024, 12:05 PMCLOVIS
10/25/2024, 12:20 PMfun foo {
with LoggerScope()
<http://log.info|log.info> { "Test" }
}
Compared to the with(a, b)
approach, this has the benefits that:
• No need to invent a new concept of n-ary type parameters (which are a very complex can of worms)
• This is purely syntax sugar, so there is no need for binary compatibility or anything else
• Doesn't force us to introduce a new indentation level each time we want to add something in the context