Reputation: 31
I am a beginner on Ada language and I would like to know what notations means. I have read in Kreuger software reuse paper that Anna is a an annotation language to describe Ada. Is that consider to be a formal comment for Ada code ?
For example:
subtype EVEN is INTEGER;
--| where X : EVEN = ) X mod 2 = 0;
The 2nd line is Anna annotation for the first line which is Ada code. Is the 2nd line just a comment to let the user understand the first line or is it a constraint that is a "must" to mention not just an optional line?
I am really confused
Upvotes: 2
Views: 610
Reputation: 31
EVEN is integer with the constraint of being, well, even. So the 2nd line is a constraint. But it will not be checked by the compiler -- and, to the best of my knowledge, the Anna toolset has never been able to check such constraints.
Anna is ancient and long gone -- but the recent Ada standard (Ada 2012) supports such annotations (which can even be checked by the compiler). So your Ada/Anna expression could be written in Ada 2012 as
subtype Even is Integer with Dynamic_Predicate => Even mod 2 = 0;
This is actually an example from the Ada 2012 rationale, see Ada 2012.
Upvotes: 3
Reputation: 8522
Anna is ancient, do not waste your time with it.
There are a number of places to get starting with Ada. Among them is the Ada Wikibook, and the Ada Information Clearinghouse (AdaIC) maintains a list of suggested resources.
If you're interested in formal logic as it applies to Ada, you'll want to look into SPARK ("SPARK is a programming language, a set of source code analysis (static verification) tools, and a design method for developing high-assurance software.") Here's a quick overview and tutorial, though you may not want to tackle that until you've got some practice with Ada under your belt.
You probably already know about the GNAT compiler, but just in case, GNAT GPL 2012 is an open source compiler available for Linux, Windows, and a few other platforms. (GNATPro is available for many platforms.)
Good luck, ask questions here, other resources include comp.lang.ada and the Ada sub-reddit.
Upvotes: 3