I understand one of the big deals about constants is that you don\'t have to go through and update code where that constant is used all over the place. Thats great, but let\'s s
There is another benefit, stack and data segment sizes.
Consider:
function Recurser(i : Integer) return Integer is
ia : array(0..9) of Integer
:= (1, 2, 3, 4, 5, 6, 7, 8, 9, 1000);
r : Integer;
begin
if i = 0 then return 0; end if;
r := ia(i mod 10);
return r + Recurser(i - 1);
end;
Every time that function recurses you create a 320 byte structure on the Stack. But since the value of a doesn't change the stack is increasing to hold a variable that is constant. This can be very important on embedded platforms with small stacks.
Package level variables also increase the size of the data segment. Pushing up your memory requirements.