Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Benchstat comparison
Results
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Unfortunately, adding new built-ins causes checking errors for several deployed contracts, as we do not allow shadowing of built-ins, and I guess we could introduce a |
|
ah I see!
This sounds like a good idea. I guess we would have to limit it for |
|
We already ran into this problem in #3055, and had started discussing a solution there: #3055 (comment) From @dete:
Swift does that for some functions, like |
|
Regarding These functions are also not tied to numeric types, but useful for any comparable type. In that sense defining them in a |
fc97a02 to
32abb30
Compare
|
I kept it simple and took inspiration from Kotlin, where the functions have an |
32abb30 to
5e12934
Compare
SupunS
left a comment
There was a problem hiding this comment.
kept it simple and took inspiration from Kotlin, where the functions have a Of suffix
That's a great idea!
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Co-authored-by: Raymond Zhang <[email protected]>
Description
Implement FLIP 357: Add minOf and maxOf Functions to Cadence.
Add new functions
minOf<T>(T, T)andmaxOf<T>(T, T), whereTmust be comparable (we can't express this with a type bound yet).The tests are currently only run with the interpreter, just like the rest of the stdlib tests. I left a TODO in #3804 to refactor all tests to be also run with the compiler/VM.
The names are not
min/max, as existing contracts commonly use these names e.g. in variable declarations, and would break, as we do not allow shadowing of built-in functions. The names are taken from Kotlin: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.comparisons/min-of.htmlmasterbranchFiles changedin the Github PR explorer