https://kotlinlang.org logo
#library-development
Title
# library-development
m

mbonnin

11/22/2021, 4:01 PM
How bad is it to use
@OptIn(ExperimentalContracts::class)
in a library? Looks like
contracts {}
blocks do not generate any bytecode (besides metadata?) so as long as it's only used internally it should be fine?
j

Javier

11/22/2021, 5:10 PM
it is used by stdlib in all places, I guess the only problem is you will have to refactor the implementation when they finish the contracts API (if it changed)
🙏 1
👌 1
b

Ben Woodworth

11/22/2021, 6:20 PM
Yeah, the KEEP says contracts are pretty much binary stable: • Syntax for declaring contracts (i.e. Contracts DSL) is unstable at the moment, and it's possible that it will be completely changed in the future. ◦ It means that writing your own contracts isn't suited for production usage yet • Binary representation (in Kotlin Metadata) is stable enough and actually is a part of stdlib already. It won't be changed without a graceful migration cycle. ◦ It means that you can depend on binary artifacts with contracts (e.g. stdlib) with all usual compatibility guarantees • Semantics, as usual, may be changed only in exceptional circumstances and only after graceful migration cycle ◦ It means that you can rely on the analysis made with the help of contracts, as it won't get broken suddenly
🙏 1
m

mbonnin

11/22/2021, 7:33 PM
Nice, thanks !!
😁 1
4 Views