Re:Programming Languages Going Above and Beyond
by lionkor on Thursday June 29, 2023 @09:30AM
(#36520097)
> Rust has Design by Contract capabilities via the contracts crate
And C++ has reflection using boost ;)
Re:Programming Languages Going Above and Beyond
by thesuperbigfrog on Thursday June 29, 2023 @09:33AM
(#36520132)
Contracts for C++ have been proposed:
https://www.reddit.com/r/cpp/comments/cmk7ek/what_happened_t...
Not sure if / when they will land:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p05...
Re:Programming Languages Going Above and Beyond
by jakuj on Thursday June 29, 2023 @10:12AM
(#36520595)
You might be interested in the Prusti project, which statically checks for absence of reachable panics, overflows etc. It also allows user-defined specifications such as pre and post-conditions, loop body invariants, termination checking and so on.
Re:Programming Languages Going Above and Beyond
by perlgeek on Thursday June 29, 2023 @10:29AM
(#36520820)
In Eiffel at least, the contracts are checked at run time, whereas in Dafny it seems that it's verified at compile time.
I think (but I'm not sure) that Eiffel disables recursive contract checking (so checking a contract of a function used for checking the contract), so you could put the check for the inverse in each of the function's post conditions, but it would be quite the performance hit to verify it at each call.
Ada supports Design by Contract preconditions, postconditions, and type invariants that were pioneered by the Eiffel programming language:
https://learn.adacore.com/courses/intro-to-ada/chapters/cont...
The SPARK subset of Ada also does static proofs / formal verification:
https://learn.adacore.com/courses/intro-to-spark/chapters/01...
===
Rust has Design by Contract capabilities via the contracts crate:
https://docs.rs/contracts/latest/contracts/
Maybe one day Rust will have formal verification too?
Work is under way: https://alastairreid.github.io/automatic-rust-verification-t...