Ada Programming/Attributes/'Width

From Wikibooks, open books for an open world
Jump to: navigation, search

Ada Lovelace 1838.jpg

Contents


[edit] Description

X'Width is an Ada attribute where X is any discrete type. This attribute represents the number of characters it takes to represent the "longest" type value using the X'Image attribute.

[edit] Example

type My_Enum is (Big, Bigger, Biggest);
...
pragma Assert (My_Enum'Image (Biggest) = "BIGGEST" );
pragma Assert (My_Enum'Width = 7); 
-- Width of "BIGGEST" is seven
-- Width of "BIG" and "BIGGER" are irrelevant.

[edit] See also

[edit] Wikibook

[edit] Ada Reference Manual

Personal tools
Namespaces
Variants
Actions
Navigation
Community
Toolbox
Sister projects
Print/export