On 15/09/2013 15:20, Marc Santhoff wrote:
It's not in question how to implement global objects. Some are
singletons by design and others are not in code but work like they were,
because the only place the constructor is (allowed to be) called is the
inittialization section.

The qeustion is where to store those objects.

1)

global war, but in implementation

interface
procedure GetFoo: TFoo;
property Foo read GetFoo;

implementation
var TheFoo: TFoo = nil;
procedure GetFoo: TFoo;
begin
  if TheFoo= nil then TheFoo:= TFoo.Create;
  REsult := TheFoo;
end;


Or, in the GetFoo

implementation
procedure GetFoo: TFoo;
const TheFoo: TFoo = nil;
begin
  if TheFoo= nil then TheFoo:= TFoo.Create;
  REsult := TheFoo;
end;



--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to