News for hackers. Stuff that matters.
Re:Ada for the C++ and Java Developer [pdf] by agumonkey on Sunday March 28, 2021 @05:56PM (#26615044)
I never understood how is that different from decorating your function with `assert` statements. Is it analyzed statically ?
Re:Ada for the C++ and Java Developer [pdf] by Jtsummers on Sunday March 28, 2021 @06:11PM (#26615177)
Yes. SPARK/Ada will attempt to verify many of the properties statically. Not everything can be, and not everything can be done without significant effort (that is, more than it may be worth). But it's more than asserts in most other languages which are only verifiable dynamically. For those areas where SPARK can't prove something statically, the checks are used at runtime (like a traditional assert). It's a best of both worlds situation, in that regard.
Re:Ada for the C++ and Java Developer [pdf] by rramadass on Monday March 29, 2021 @12:45AM (#26617786)
asserts are just a language mechanism using which you implement preconditions/postconditions/invariants which are program correctness design constructs. Thus it is a systematic (i.e. not ad-hoc) way of using asserts correctly to guarantee program state.

I highly recommend reading Bertrand Meyer's papers "Applying Design By Contract" and "Design by Contract". They are well worth every programmer's time.

Re:Ada for the C++ and Java Developer [pdf] by boibombeiro on Sunday March 28, 2021 @06:14PM (#26615199)
You can use formal verification tools to verify the code. Having preconditions ("assume" instead of "assert") reduces the search space.