Skip to content
Hub Nexus

No author yetClaim it

Version 1Updated 5 min read

Support

Computing » Computer Science » Computer Programming » Ada Programming

When entities like variables or subprograms are declared, certain properties thereof normally are left to the compiler to specify (like the size or the address of a variable, the calling convention of a subprogram). Properties which may be queried are called Attributes; those which may be specified are called Aspects.
Aspects and attributes are defined in the Ada Reference Manual annex Annex K: Language-Defined Aspects and Attributes [Annotated].

Language summary attributes

The concept of attributes is pretty unique to Ada. Attributes allow you to get —and sometimes set— information about objects or other language entities such as types. A good example is the Size attribute. It describes the size of an object or a type in bits.

A : Natural := Integer'Size; -- A is now 32 (with the GNAT compiler for the x86 architecture)

However, unlike the sizeof operator from C/C++ the Size attribute can also be set:

type Byte

  • is range -128 .. 127; -- The range fits into 8 bits but the
    -- compiler is still free to choose.
    for Byte'Size use 8; -- Now we force the compiler to use 8 bits.

Of course not all attributes can be set. An attribute starts with a tick ' (apostrophe) and is followed by its name. The compiler determines by context if the tick is the beginning of an attribute, a character literal or a quantified expression.

A : Character := Character'Val (32); -- A is now a space
B : Character := ' '; -- B is also a space
S : String  := Character'(')')'Image; -- an especially nice parsing exercise

List of language defined attributes

Ada 2005
This is a new Ada 2005 attribute.
Ada 2012
This is a new Ada 2012 attribute.
Ada 2022
This is a new Ada 2022 attribute.
Obsolescent
This is a deprecated attribute and should not be used in new code.

A – B

'Access

C

D – F

G – L

M

O – R

S

T – V

W – Z

List of implementation defined attributes

The following attributes are not available in all Ada compilers, only in those that had implemented them.

Currently, there are only listed the implementation-defined attributes of a few compilers. You can help Wikibooks adding specific attributes of other compilers:

GNAT
Implementation-defined attribute of the GNAT compiler from AdaCore/FSF.
HP Ada
Implementation-defined attribute of the HP Ada compiler (formerly known as "DEC Ada").
ICC
Implementation-defined attribute1] of the Irvine [ICC compiler.
PowerAda
Implementation-defined attribute of OC Systems' PowerAda.
SPARCompiler
Implementation-defined attribute of Sun's SPARCompiler Ada.

A – D

E – H

I – N

O – T

U – Z

See also

Wikibook

Ada 83

Ada 95

Ada 2005

Ada 2012

Ada 2022

References

  • ↑ "4.2 ICC-Defined Attributes", ICC Ada Implementation Reference — ICC Ada Version 8.2.5 for i960MC Targets, document version 2.11.4 [1]

Where this page came from

This page was imported from Wikibooks. From “Ada Programming” on Wikibooks, by its contributors, under CC BY-SA 4.0. Changed here: set as a page; navigation and edit links left out; each image under its own licence, credited in its caption.

Nobody has written it yet — it is the source material at a new address, which is why search engines are asked to skip it and why no one earns from it. It is up for grabs: take it on, and it is yours to rewrite and to earn from.

Comments

Spinner Logo

Next in Ada Programming

CC BY-SA 4.0
[Computing]( » [Computer Science]( » [Computer Programming]( » [Ada Programming]( When entities like variables or subprograms are declared, certain properties thereof normally are left to the compiler to specify (like the size or the address of a variable, the calling convention of a subprogram). Pr
CC BY-SA 4.0
[Computing]( » [Computer Science]( » [Computer Programming]( » [Ada Programming]( The **Standard** package is implicit. This means two things: - You do not need to [with]( or [use]( the package, in fact you cannot (see below). It's always available (except where hidden by a homograph, RM [8.3 (8)](
CC BY-SA 4.0
[Computing]( » [Computer Science]( » [Computer Programming]( » [Ada Programming]( The **Ada** package is only an anchor or namespace for Ada's standard library. Most compilers will not allow you to add new packages to the Ada hierarchy and even if your compiler allows it you should not do so since a
CC BY-SA 4.0
[Computing]( » [Computer Science]( » [Computer Programming]( » [Ada Programming]( The Interfaces package helps in interfacing with other programming languages. Ada is one of the few languages where interfacing with other languages is part of the language standard. The language standard defines the i
CC BY-SA 4.0
[Computing]( » [Computer Science]( » [Computer Programming]( » [Ada Programming]( ## Forges of open-source projects [SourceForge]( Currently, there are more than 200 Ada projects hosted at SourceForge — including the example programs for [Ada Programming]( wikibook. [GitHub]( A source code repositor