Better support for type composition patterns

while kotlin does allow a bit of composition using delegates for interfaces, i feel the story around composition is still lacking.

for eg, there is no way to get composition by field.
so if i wanted to compose a data class by adding in 2 other data classes, currently there is no way to do that.

golang allows this very elegantly.
Typescript leads the way by allowing you to Pick and even Exclude members of a type.

i hope we can start a discussion around introducing better support of various composition patterns inside kotlin. The current delegation mechanism is a start, but not even close to comprehend.

1 Like