Figure 26.
Objects need a constraint.
-----------------------------------------------------------
-- This procedure illustrates the consequences of LRM
-- Section 3.7.2 paragraph 8.
procedure Objects_Need_A_Constraint is
type No_default (LENGTH : natural) is
record
TEXT : string(1..LENGTH);
end record;
type Default (LENGTH : natural := 0) is
record
TEXT : string(1..LENGTH);
end record;
FIRST_NAME : No_default(8);
MY_NAME : No_default; -- illegal
WHOLE_NAME : Default(14);
LAST_NAME : Default;
-- MY_NAME is illegal because no constraint was
-- supplied (as it was for FIRST_NAME).
-- LAST_NAME doesn't need a constraint because there
-- is a default value for it.
-- WHOLE_NAME shows that you can give a constraint
-- that is different from the default value if you like.
begin
null;
end Objects_Need_A_Constraint;