Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikibooksThe Free Textbook Project
Search

Ada Programming/Keywords/for

From Wikibooks, open books for an open world
<Ada Programming |Keywords
Computing »Computer Science »Computer Programming »Ada Programming

Ada. Time-tested, safe and secure.
Ada. Time-tested, safe and secure.


This keyword is used in:

  • For loops
  • Representation clauses:
    • attribute definition clause
    • enumeration representation clause
    • record representation clause
    • at clause (obsolescent)
  • Quantified expressions
    • Universal quantification
    • Existential quantification

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

For loops

[edit |edit source]
[loop name:]forvarin [reverse ] [typerange]rangeloop   ...endloop [loop name];

Whererange can be:

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

Keywordin may also be followed by aniterable. This generalizes iteration by including types that have one of the interfaces defined inAda.Iterator_Interfaces.This language feature has been introduced inAda 2012.

Another generalized form of looping iteration uses the keywordof in place ofin. The loop parameter is then referring to components of arrays or of iterable container types, directly.This language feature has been introduced inAda 2012.

[loop name:]forvar [:type]of [reverse ]iterableloop   ...endloop [loop name];

Representation clauses

[edit |edit source]

The keywordsfor,use andat are used for representation clauses.

A record representation clause specifies theLayoutaspect of a record.

An enumeration representation clause specifies theCodingaspect of an enumeration type.

SeeAda Programming/Representation_clauses.

Quantified expressions

[edit |edit source]

This language feature has been introduced inAda 2012.

Quantified expressions are Boolean expressions. They are eitherTrue orFalse, or propagate any exception raised during evaluation.

Universal quantification

[edit |edit source]

Universal quantification expression:

(forallvarinrange=>predicate)(forallvarofiterable=>predicate)

Both forms evaluate toTrue when all of the values inrange (ofiterable) make thepredicate yieldTrue. Evaluation ofpredicate stops when either all values of loop parametervar have been exhausted, or when evaluation for some value yieldsFalse (short circuit).

Existential quantification

[edit |edit source]

Existential quantification expression:

(forsomevarinrange=>predicate)(forsomevarofiterable=>predicate)

Both forms evaluate toTrue when some of the values inrange (ofiterable) makes thepredicate yieldTrue. Evaluation ofpredicate stops when either all values of loop parametervar have been exhausted, or when evaluation for some value yieldsTrue (short circuit).

See also

[edit |edit source]

Wikibook

[edit |edit source]

Ada Reference Manual

[edit |edit source]

Ada 83

[edit |edit source]

Ada Quality and Style Guide

[edit |edit source]

References

[edit |edit source]
  1. John Barnes (2003-03-25).High-Integrity Software — The SPARK Approach to Safety and Security. Addison-Wesley.ISBN 0-321-13616-0. Retrieved2008-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
abortelsenewreturn
abselsifnotreverse
abstract (Ada 95)endnull
acceptentryselect
accessexceptionofseparate
aliased (Ada 95)exitorsome (Ada 2012)
allotherssubtype
andforoutsynchronized (Ada 2005)
arrayfunctionoverriding (Ada 2005)
attagged (Ada 95)
genericpackagetask
begingotoparallel (Ada 2022)terminate
bodypragmathen
ifprivatetype
caseinprocedure
constantinterface (Ada 2005)protected (Ada 95)until (Ada 95)
isuse
declareraise
delaylimitedrangewhen
deltalooprecordwhile
digitsremwith
domodrenames
requeue (Ada 95)xor
Retrieved from "https://en.wikibooks.org/w/index.php?title=Ada_Programming/Keywords/for&oldid=4036630"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp