2 ms·
You may want to check out Ada, then: https://docs.adacore.com/spark2014-docs/html/ug/en/source/type_contracts.html https://docs.adacore.com/spark2014-docs/html/
by johnisgood 6y ago
You may want to check out Ada, then: https://docs.adacore.com/spark2014-docs/html/ug/en/source/type_contracts.html https://docs.adacore.com/spark2014-docs/html/ug/en/source/ty...
You can catch a hell lot of things at compile-time. Correctness is huge in Ada/SPARK. You write safety-critical software in it. I have a comment on Ada/SPARK in great detail, but I do not have the time to find it sadly. :(
Consider this:
Total : Integer range 0 .. Integer'Last
"Any attempt to assign a negative value to variable Total results in raising an exception at run time. During analysis, GNATprove checks that all values assigned to Total are positive or null."
Analysis here means static analysis.
You can do stuff like this, too, for example:
subtype Natural is Integer range 0 .. Integer'Last;
subtype Positive is Integer range 1 .. Integer'Last;
The above is actually declared in the visible part of package Standard.
- volta83 6y agoDoes Ada perform layout optimizations on the niches ?
- johnisgood 6y agoI think the terminology is completely different, so I am not quite sure. Perhaps someone who knows Ada/SPARK and its compiler better may be able to answer you.