[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:

interface

function foo: tfoo;

implementation

var
   _foo: tfoo;

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

Is it safe?

--
Joao Morais




More information about the fpc-pascal mailing list