I’m more familiar with Rust’s module system. In Ko...
# getting-started
t
I’m more familiar with Rust’s module system. In Kotlin, I’m sometimes tempted to create a package that contains a single file, with a few top-level declarations. But that results in a directory containing a single file. Is this bad practice? What are the alternatives? A file with a bunch of public declarations? A file with a top-level class to contain the declarations?
h
What do you really want, a namespace? Kotlin does not have namespace but packages. A single file in a package is absolutely okay, but it is just a name. Kotlin does not have package-private visibility and you can always add an import so I would not overuse packages but have bigger packages, to have better auto complete/visibility. The name of the actual classes/functions is more important than the package name.
t
Soooo... just put it into a file (along side others in a higher-level package) and don't worry about it being visible outside?
I find the lack of package-private visibility extremely odd.
h
If you worry, make it internal, only visible in the module.
👍 1
h
If you want a package-private modifier, you should vote for KT-29227 – it's currently the third-highest voted open issue on the Kotlin issue tracker...