https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
f

Federico d'Alonzo

11/21/2023, 5:50 PM
Hello! This is something that just came to mind: are there plans to bring open/override behaviours to expect/actual functions? And possibly classes, but as interfaces+expect-fun are recommended, the behaviour limited to functions could probably(?) be easier to implement and encourage interfaces. By that I mean to make this syntax valid, creating an open (or via soft "default" modifier keyword) function implementation like so:
Copy code
public open expect fun FooBar(): FooBar {/***/}
in a common group in the tree (like native or ios). And to have, when possible, an open (implicit) or final (explicit) actual fun with the platform implementation. The simple pair of expect/actual behaviour can be implemented by simply defining a
defaultFooBar
fun in the common group and actualizing whenever needed by calling that function from
FooBar
. But the possibility of eventually overriding the generic implementation, or an open override implementation down the chain is only possible using an expect/actual chain, which could become cumbersome. It's certainly not a needed feature, but a possible syntactic sugar for the future.
2 Views