I see Explicit API mode (<https://github.com/Kotli...
# language-evolution
w
I see Explicit API mode (https://github.com/Kotlin/KEEP/blob/master/proposals/explicit-api-mode.md) is included in 1.4-M2 such that
public
visibility modifier is required. So now all declarations will require either
public
modifier or
private/internal
. Is making
internal
visibility default in this mode on the table?
i
No, it's out of scope of this proposal.
👍 1
w
Thanks 🙂 Is default visibility discussed elsewhere, perhaps? In general I’m interested if it’s something that’s considered at all (possibly after gathering feedback on the current explicit API mode)
r
To my understanding, toggling explicit API mode has to keep code semantics, just enable additional explicitness requirements (see Compatibility section in the end of the document you've linked). So changing default visibility mode sounds to me (as a person unrelated to Kotlin development, of course) like a thing which isn't a topic for discussion.
e
➕ There are no ongoing discussions on changing default visibility. One reason is that the ship has sailed, the other reason is that our practice shows that Kotlin default public visibility is a very reasonable default for the majority of the code that is being written in Kotlin and had stood the test of time well. The “explicit API” mode is designed to the help the minority that is writting non-typical (library) code.
w
Thanks for answering 🙂 That sounds reasonable. The reason I’m asking is I’m not in the library-writing minority, but with modularised app’s codebase (Android & Gradle) we tend to hide declarations not intended for consumption by other modules. I believe (but I’m not 100% sure) it helps with incremental compilation, since declarations public “by accident” will cause consumers to recompile unnecessarily. And since majority of the classes in those separate modules should be internal, I was just hoping I could switch the default visibility for convenience.