Context-dependent method dispatch

5 views
Skip to first unread message

Matthew Browne

unread,
Dec 30, 2025, 11:40:44 PM (2 days ago) 12/30/25
to object-co...@googlegroups.com
I thought this article was interesting:

https://proandroiddev.com/an-introduction-context-oriented-programming-in-kotlin-2e79d316b0a2

It seems that the Kotlin language has accidentally discovered a
context-sensitive alternative to traditional double dispatch. There are
many similarities with C# extension methods or Rust extension traits (to
the extent that I understand those), but the later examples in the
article show some features that might be unique to Kotlin.

Kotlin's extension functions could definitely be used to implement a
form of DCI...I haven't tried it (yet), so I'm not sure how well it
would work. But it seems like an interesting tool for role-based
programming in any case.


Reply all
Reply to author
Forward
0 new messages