Ada Programming/Keywords/for

From Wikibooks, the open-content textbooks collection

Jump to: navigation, search

Ada Lovelace 1838.jpg

Contents


This keyword is used in:

Nowadays representation clauses are formally called aspect clauses in the last versions of the Reference Manual due to some technicalities, although representation clauses is the name far more extended among Ada programmers. As a historical note, they were known as representation specifications (rep specs) in pre-Ada 83 proposals.[1]

[edit] For loops

[loop name :] for var in [[[Ada Programming/Keywords/reverse|reverse]]] [type range] range loop
   ...
end loop;

Where range can be:

  • explicit range like "low .. high",
  • range of scalar or array type: type'Range (or type'Range(n) for multidimensional array types)
  • range of an array: array'Range (or array'Range(n) for multidimensional arrays)

[edit] Representation clauses

[edit] Attribute definition clause

for id'attribute use value;

Where attribute can be any specifiable attribute.

[edit] Enumeration representation clause

for enumeration type use (enum1 => value1, enum2 => value2, ...);

[edit] Record representation clause

for record type use
  record
     component1 at offset range first bit 1 .. last bit 1;
     component2 at offset range first bit 2 .. last bit 2;
     ...
  end record;

[edit] At clause (obsolescent)

At clauses are obsolescent since Ada 95:

for id use at address;

where address is of the type System.Address.

An at clause is equivalent to "for id'Address use address;". Since Ada 95 this is the preferred method.

[edit] See also

[edit] Wikibook

[edit] Ada Reference Manual

[edit] Ada 83

[edit] Ada Quality and Style Guide

[edit] References

  1. John Barnes (2003-03-25). High-Integrity Software — The SPARK Approach to Safety and Security. Addison-Wesley. ISBN 0-321-13616-0. Retrieved on 2008-06-06. “Representation clauses are now strictly known as aspect clauses — the name was changed in the 2000 Corrigendum for Ada 95 for subtle reasons that need not concern us; Ada historians might recall that they were known as representation specifications (rep specs) prior to the ANSI standardization in 1983. These various terminologies are all in use and the reader will encounter them in the literature. (pp.212–213)”



Ada Keywords
abort else new return
abs elsif not reverse
abstract (Ada 95) end null
accept entry select
access exception of separate
aliased (Ada 95) exit or subtype
all others synchronized (Ada 2005)
and for out
array function overriding (Ada 2005) tagged (Ada 95)
at task
generic package terminate
begin goto pragma then
body private type
if procedure
case in protected (Ada 95) until (Ada 95)
constant interface (Ada 2005) use
is raise
declare range when
delay limited record while
delta loop rem with
digits renames
do mod requeue (Ada 95) xor