[fpc-pascal] Re: classes initialization

Joao Morais post at joaomorais.com.br
Tue Mar 25 14:21:50 CET 2008

Jonas Maebe wrote:
> Using uninitialised variables is virtually always bad, regardless of the 
> scope. And the fact that global variables are zeroed at the program 
> start is afaik not defined by the Pascal standard. It's just a side 
> effect of the way most operating systems work.

I think I didn't get your point. What about this piece of code:


function foo: tfoo;


   _foo: tfoo;

function foo: tfoo;
   if not assigned(_foo) then
     _foo := tfoo.create;
   result := _foo;

Is it safe?

Joao Morais

More information about the fpc-pascal mailing list