Ada Programming/Pragmas/Normalize Scalars

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

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

Summary[edit | edit source]

The pragma Normalize_Scalars directs the compiler to initialize otherwise uninitialized scalar variables with predictable values. If possible, the compiler will choose out-of-range values.

Example[edit | edit source]

pragma Normalize_Scalars;
...
My_Variable : Positive; -- Oops, forgot to initialize this variable.
                        -- The compiler (may) initialize this to 0
...
-- Oops, using a variable before it is initialized!
-- An exception should be raised here, since the compiler
-- initialized the value to 0 - an out-of-range value for the Positive type.
Some_Other_Variable := My_Variable;

See also[edit | edit source]

Wikibook[edit | edit source]