Ada Programming/Attributes

From Wikibooks, the open-content textbooks collection

Jump to: navigation, search

Ada Lovelace 1838.jpg

Contents


[edit] 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 ' and is followed by its name. The compiler determines by context if the tick is the beginning of an attribute or of a character literal.

A : Character := Character'Val (32) -- A is now a space
B : Character := ' ';               -- B is also a space

[edit] List of language defined attributes

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

[edit] A – B

[edit] C

[edit] D – F

[edit] G – L

[edit] M

[edit] O – R

[edit] S

[edit] T – V

[edit] W – Z

[edit] 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 attribute[1] of the Irvine ICC compiler.
PowerAda 
Implementation-defined attribute of OC Systems' PowerAda.
SPARCompiler 
Implementation-defined attribute of Sun's SPARCompiler Ada.

[edit] A – D

[edit] E – H

[edit] I – N

[edit] O – T

[edit] U – Z

[edit] See also

[edit] Wikibook

[edit] Ada Reference Manual

[edit] Ada 83

[edit] Ada 95

[edit] Ada 2005

[edit] References

  1. "4.2 ICC-Defined Attributes", ICC Ada Implementation Reference — ICC Ada Version 8.2.5 for i960MC Targets, document version 2.11.4[1]
In other languages