[fpc-pascal] readonly variables

Michael Van Canneyt michael at freepascal.org
Sat Nov 28 21:33:16 CET 2009

On Sat, 28 Nov 2009, Anthony Walter wrote:

>> This is not guaranteed in any way. It happens to be so most of the time,
>> but your code should never assume this is so, except for global Ansistring
>> variables.
> If all globals weren't initialized to 0 a lot of code from lots of
> people would potentially be in trouble. I've been using Pascal/Delphi
> for a very long time. Trust me I know my stuff.

I believe that. I know it is so in practice, but nowhere it says in the 
Pascal language specification that this is guaranteed by the compiler.

>> From the language specification:
> Section: Data Types, Variables, and Constants
> Sub-section: Declaring Variables
> Page: 102
> "If you don't explicitly initialize a global variable, the compiler
> initializes it to 0."

That should be removed, actually.


More information about the fpc-pascal mailing list