Ada Programming/Libraries/Standard

The Standard package is implicit. This means two things:


 * 1) You do not need to  or  the package, in fact you cannot (see below) . It's always available (except where hidden by a homograph, RM ).
 * 2) Standard may contain constructs which are not quite legal Ada (like the definitions of Character and Wide_Character).

A clause mentioning Standard references a user-defined package Standard that hides the predefined one. So do not do this. However any library unit hidden by a homograph can be made visible again by qualifying its name with Standard, like e.g. Standard.My_Unit.

Implementation
Since the package Standard is very important for portability, here are some examples for various compilers:


 * The package Standard from ISO 8652.
 * The package Standard from GNAT.
 * The package Standard from Rational Apex.
 * The package Standard from ObjectAda
 * The Standard definitions for AppletMagic

Portability
The only mandatory types in Standard are Boolean, Integer and its subtypes, Float, Character, Wide_Character, Wide_Wide_Character, String, Wide_String, Wide_Wide_String, Duration. There is an implementation permission in RM (51) that there may be more integer and floating point types and an implementation advice RM (52) about the names to be chosen. There even is no requirement that those additional types must have different sizes. So it is e.g. legal for an implementation to provide two types Long_Integer and Long_Long_Integer which both have the same range and size.

Note that the ranges and sizes of the numeric types can be different in every platform. There is an implementation requirement that the size of type Integer is at least 16 bits, and that of Long_Integer at least 32 bits (if present) RM (21..22). There is also an implementation permission RM (25) that further types whose names indicate smaller ranges like Short_Integer (if present) do not in fact have ranges greater than those indicating larger ranges. There is, however, an implementation advice RM (28) that there should be no other integer types in Standard than Integer and Long_Integer; instead, those hardware adapted types should be defined in package Interfaces RM. So if you want full portability of your types, do not use types from Standard (except where you must, see below), rather define you own types. A compiler will reject any type declaration whose range it cannot satisfy.

This means e.g. if you need a 64-bit type and find that with your current implementation Standard.Long_Long_Integer is such a type, when porting your program to another implementation, this type may be shorter, but the compiler will not tell you - and your program will most probably crash. However, when you define your own type like

My_Integer_64  -(2**63) .. +(2**63 - 1);

then, when porting to an implementation that cannot satisfy this range, the compiler will reject your program.

The type Integer is mandatory when you use [[wide] wide] strings or exponentiation x**i. This is why some projects even define their own strings, but this means throwing out the child with the bath tub. Using Integer with strings and exponentiation will normally not lead to portability issues.

Wikibook

 * Ada Programming
 * Ada Programming/Libraries

Ada Quality and Style Guide

 * – Avoid using the package ASCII
 * – Avoid the predefined numeric types

|Standard

Programación en Ada/Unidades predefinidas/Standard