4 ms·
Contracts are interesting but I think to make it usefull 1) are ON on release! and 2) Become part of the docs. One example: fun date(y:i32, m:i32, d:i32)
by mamcx 7y ago
Contracts are interesting but I think to make it usefull 1) are ON on release! and 2) Become part of the docs.
One example:
fun date(y:i32, m:i32, d:i32)
{... code ...}
This scream for more context (and better param names!). With contracts:
fun date(y:i32, m:i32, d:i32)
assert
y in 0..9999
m in 1..12
d in 1..31
{... code ...}
But I need to see it in the docs, in the tooltips, etc. Now are useful!
- klipt 7y agoGood old February 31.
- mamcx 7y agoNothing like a bug behind a safety feature :)
- elgenie 7y agoThat’s … not a bug. A buggy assertion would be one that fires when the input is correct. Assertions aren’t formal verifiers or replacements for a test suite.
- squarefoot 7y agoObligatory reference:) https://www.youtube.com/watch?v=sVyRkl5qNb8 https://www.youtube.com/watch?v=sVyRkl5qNb8
- masonic 7y agoAnd year 0.
- mamcx 7y agoI think that is why making the contract visible in the docs/intellisense or similar is valuable: You will understand more about the expectations of the code. Even if are incomplete or partial...
- mhd 7y ago> (and better param names!) And/or better param (sub-)types.