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

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to