Skip to content

Commit

Permalink
Added local package alternative for static object
Browse files Browse the repository at this point in the history
  • Loading branch information
elizarov committed Mar 25, 2023
1 parent d53500b commit 260dd37
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions proposals/statics.md
Original file line number Diff line number Diff line change
Expand Up @@ -1898,3 +1898,9 @@ First, it requires `static` to become a hard keyword on par with `fun`, `class`,
a way more disruptive and more breaking change. Second, it breaks the spirit of Kotlin design that tries to minimize the
number of core concepts, opting to modify them instead. Kotlin does not have `enum`, but `enum class`, Kotlin does
not have `record` but `data class`, etc. It is in Kotlin spirit to have `static object` as opposed to a separate concept.

Another alternative for the `static object` concept is a "local package". That is, we can add `package XXX {}` syntax
instead of `static object XXX {}`. The package and the static object are really similar — they contain the same kind
of static declarations, they are imported in a similar way, etc. Two downsides of this choice are differences in the
naming convention that are already established (lowercase for packages and camelcase for objects) and the confusion
it might cause on JVM, as local packages will not be represented by packages on JVM.

0 comments on commit 260dd37

Please sign in to comment.