Ada (programming language): Difference between revisions

Content deleted Content added
Citation bot (talk | contribs)
Altered isbn. Upgrade ISBN10 to 13. | Use this bot. Report bugs. | Suggested by Headbomb | Linked from Wikipedia:WikiProject_Academic_Journals/Journals_cited_by_Wikipedia/Sandbox | #UCB_webform_linked 50/748
Tag: Reverted
Line 191:
Types can have modifiers such as ''limited, abstract, private'' etc. Private types do not show their inner structure; objects of limited types cannot be copied.<ref>{{cite web |title=Ada Syntax Card |url=http://www.digilife.be/quickreferences/QRC/Ada%20Syntax%20Card.pdf |access-date=28 February 2011 |url-status=dead |archive-url=https://web.archive.org/web/20110706133825/http://www.digilife.be/quickreferences/QRC/Ada%20Syntax%20Card.pdf |archive-date=6 July 2011}}</ref> Ada 95 adds further features for object-oriented extension of types.
 
=== Control structures ===
Ada is a [[structured programming]] language, meaning that the flow of control is structured into standard statements. All standard constructs and deep-level early exit are supported, so the use of the also supported "[[goto (command)|go to]]" commands is seldom needed.
 
<syntaxhighlight lang="ada" line>
-- while a is not equal to b, loop.
while a /= b loop
Ada.Text_IO.Put_Line ("Waiting");
end loop;
 
if a > b then
Ada.Text_IO.Put_Line ("Condition met");
else
Ada.Text_IO.Put_Line ("Condition not met");
end if;
 
for i in 1 .. 10 loop
Ada.Text_IO.Put ("Iteration: ");
Ada.Text_IO.Put (i);
Ada.Text_IO.Put_Line;
end loop;
 
loop
a := a + 1;
exit when a = 10;
end loop;
 
case i is
when 0 => Ada.Text_IO.Put ("zero");
when 1 => Ada.Text_IO.Put ("one");
when 2 => Ada.Text_IO.Put ("two");
-- case statements have to cover all possible cases:
when others => Ada.Text_IO.Put ("none of the above");
end case;
 
for aWeekday in Weekday'Range loop -- loop over an enumeration
Put_Line ( Weekday'Image(aWeekday) ); -- output string representation of an enumeration
if aWeekday in Working_Day then -- check of a subtype of an enumeration
Put_Line ( " to work for " &
Working_Hours'Image (Work_Load(aWeekday)) ); -- access into a lookup table
end if;