Eveyrone knows that Delphi has typed constants.
const C: Integer = 777;
So the data of the constants is stored in the data segment (IDATA executable section is used).
But what happens when you define typed constant in a function or procedure?
Answer: The same – you just limit the scope. So typed constants are initialized when loading the executable and only once – they are not set to the value each time when you enter the function. As well these consts data is not in a stack.
procedure Run; {$J+} const C: Integer = 0; begin Inc (C); ... end;
The procedure above on each call will have value of C equal to the number of times routine is called.
So you have local global variable 🙂
May the Pascal be with you!