Elijah Verdoorn
08/20/2019, 7:01 PMsuper
. For example:
override fun onDestroy() {
super.onDestroy()
channel.close()
}
could become
super fun onDestroy() = channel.close()
The override
word becomes optional, since the call to super
only makes sense in the context of functions that are being overridden.Zac Sweers
08/20/2019, 7:02 PMLuke
08/20/2019, 7:07 PMcontinue fun onDestroy() = channel.close()
?Charles
08/20/2019, 7:09 PMcontinue
loses some of the connecting glue for me.Elijah Verdoorn
08/20/2019, 7:11 PMcontinue
is interesting to me, it reads nicely in english, but super
is pretty well-recognized syntax from other languages and might be more natural for developers coming to Kotlin for the first time from other languagesraulraja
08/20/2019, 8:05 PMelizarov
08/20/2019, 8:07 PMfun onDestroy() by withSuper { channel.close() }
This way, calling “super first” will not be hard-coded, but will be just one way to do it. Having said that, I’m not even sure that supporting super calls in function delegation worth it.Charles
08/21/2019, 12:38 AMsuper.*
in any normal override
.
In my current project this would be used nearly 1000 times. So many overrides (especially in Android) you have to follow this pattern. And it becomes code bloat.Charles
08/21/2019, 12:40 AMgildor
08/21/2019, 12:42 AMraulraja
08/21/2019, 6:34 AMcbruegg
08/21/2019, 6:41 PMElijah Verdoorn
08/21/2019, 8:14 PMsuper
. I like the generalization that has been proposed around function delegation, seems like the addition of that feature would not only enable this use-case, but also be a powerful addition to the language as a wholeraulraja
08/21/2019, 10:27 PM@super
rewrites its body to call super first and write any boilerplate you wish. Similar as to how its done in this other plugin https://github.com/47deg/arrow-meta-prototype/blob/rr-typeclasses-plugin/compiler-plugin/src/main/kotlin/arrow/meta/typeclasses/TypeClassesPlugin.kt#L43