What's the "fully qualified syntax" for extension function?


In Java and most of Kotlin if we have a function, method or class, we have a natural hierarchical way of expressing their fully qualified name, e.g.

  • pack.age.aTopLevelFun
  • pack.age.Class
  • pack.age.Class.method
  • pack.age.Class.NestedClass
  • pack.age.Class.NestedClass.method

I’m looking for a way to express extension functions a similar way for writing technical articles. I want to find a way that’s unambiguous, simple/concise, and lexicographically sortable (like the above list).

What I thought about so far

For example we have (omitting paramters for simplicity, of course they would go in parentheses):

  • Array<T>.reversed() in kotlin.collections
  • Comparator<T>.reversed() in kotlin.comparisons
  • Iterable<T>.reversed() in kotlin.collections

Note: the ambiguity is important to resolve, because we can have X.ext() in pack.a and X.ext() in pack.b too.

Omitting the receiver:

  • kotlin.collections.reversed()
  • kotlin.collections.reversed()
  • kotlin.comparisons.reversed()

results in ambiguity and doesn’t express well.

Prefixing with package:

  • kotlin.collections.Iterable<T>.reversed()
  • kotlin.collections.Array<T>.reversed()
  • kotlin.comparisons.Comparator<T>.reversed()

conflicts with the traditional fully qualified names and suggests that the receiver is in that package, which is false information.

Qualifying the function name only looks promising:

  • kotlin.Array<T>.kotlin.collections.reversed()
  • kotlin.Comparator<T>.kotlin.comparisons.reversed()
  • kotlin.collections.Iterable<T>.kotlin.collections.reversed()

but it looks like property accesses.

Any ideas, suggestions, comments are welcome.

My solution for this would be to borrow from the mutliple recievers KEEP. The current idea (I think) is to write the list of recievers in braces. So your syntax could be something like