Jeff Lockhart
08/04/2023, 5:08 PMCoroutineDispatcher
as an AbstractCoroutineContextKey
being annotated ExperimentalSdlibApi
? Is this expected to be stable in a coming coroutines library release? Is it pending anything else, or just still incubating before becoming officially stable? I'm assuming there would be a replacement for doing coroutineContext[CoroutineDispatcher]
if the API were to change?Jeff Lockhart
08/04/2023, 5:19 PMcoroutineContext[CoroutineDispatcher]
that's not an experimental API?Jeff Lockhart
08/06/2023, 3:11 AM@ExperimentalStdlibApi
is coming from AbstractCoroutineContextKey, which was introduced in Kotlin 1.3. I can't find any info about a timeline for when this experimental opt-in might not be required though. I was hoping this might be removed in a kotlinx-coroutines update, but seems it'll have to come in a Kotlin language update first.Jeff Lockhart
08/06/2023, 3:13 AMCLOVIS
08/08/2023, 7:56 AMalready opt-in to many experimental APIs in my own librariesNote that you really shouldn't be doing that, and should be propagating the experimental annotation instead. Otherwise, users of your library won't know that some code they are calling may break when updating a dependency.
CLOVIS
08/08/2023, 7:56 AM@OptIn
, not libraries.Jeff Lockhart
08/08/2023, 7:37 PMCLOVIS
08/08/2023, 7:45 PMI guess if the user were to update a library dependency that requires opt-in to a version that has removed the API, while continuing to use an old version of my library that requires those APIs, this would be a reason.
Yes, that's the reason.
But this same thing is possible for APIs that don't currently require opt-in that may be deprecated and removed in the future.
No, because a properly maintained library will only remove things in a major version, after the full depreciation cycle (warning → error → hidden). For example, to my knowledge, not a single symbol has been removed from the standard library yet, they're at most at the ‘hidden’ stage. Whereas, an opt-in symbol can be removed at any time, on any version. Let's say you depend on Coroutines and use one of their opt-in. The end user may also depend on Kotest, which requests a newer version of Coroutines. Now, your library breaks, because you're calling code that doesn't exist anymore—and the user didn't even touch the version of your library, they just added another completely unrelated one. And in this version, it's worse, because the code would work in production but fail in tests (since Kotest is not used in production). If you propagate all experimental annotations, the end user knows that stuff may break.
There are just so many opt-in APIs currently required with native and multiplatform development that would be needed to propagate on a substantial portion of my code, where opting in globally for the project is much simpler.
That's true, but that's at the cost of binary-incompatible updates... I tend to use OptIn before 1.0, and propagate after that.
Jeff Lockhart
08/08/2023, 7:59 PMI tend to use OptIn before 1.0, and propagate after that.This makes sense. My libraries have only been used internally up to now, so I haven't had to worry about consumers not updating to latest version. But I'm about to release my first library publicly. With its internal use, I consider the Android, JVM, iOS, and macOS targets stable, while the Linux and Windows targets are still experimental. So I haven't decided the version to use, whether pre-1.0 or not. But maybe propagating the opt-ins, even with a 1.0 version will help communicate this status (besides being documented as such).
CLOVIS
08/08/2023, 8:01 PMJeff Lockhart
08/08/2023, 8:04 PMlouiscad
08/08/2023, 9:56 PMJeff Lockhart
08/09/2023, 4:55 AM