by lesbaker · 7y ago · 0 comments
For example, I wondered why in the slides he felt implementing contract programming in D was a miss; it seemed like a strong selling point for the language. According to the talk (around 1:34:30), however, he felt that contract programming was relatively unpopular/unused in D and that "assert" covered most of the use cases for it.
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!A buggy assertion would be one that fires when the input is correct.
Assertions aren’t formal verifiers or replacements for a test suite.
And/or better param (sub-)types.