Re: Singleton



In article <478ea196$1@xxxxxxxxxxxxxxxxxxxxxx>, Chris Rolliston says...
You're essentially simulating a "static" variable as in C/C++ using
this ugly {$J+} switch.

In newer Delphi versions I would suggest using a private class var
instead of a global variable or a writeable constant.

It's not 'ugly'. What's wrong with static variables? It keeps the
code all together, unlike your alternatives - a global var is be
definition outside

It might help some people to sleep easier at night to
accept/acknowledge/recognise that there is no such thing as a global var
in Delphi.

Just call it an "implementation variable" rather than a "global
variable" if it makes you (ie. "them") happier.

:)

--
JS
TWorld.Create.Free;
.



Relevant Pages

  • Re: GetComputerName
    ... > - Delphi allows us to send it to APIs as a PChar ... > Some APIs perform differently between versions of Windows ... > Reporting the result of GetLastError is a pretty generic task ...
    (alt.comp.lang.borland-delphi)
  • Re: Question: how to read any one character from keyboard
    ... Doesn't anyone use Delphi anymore? ... the user at one point to "press any key" (it's a console app and this ... The help says that if you use Read with a Char var, ...
    (alt.comp.lang.borland-delphi)
  • Re: Generics for Delphi
    ... fVaribale: Array of Integer; ... Unfortunately, I can see the similarity, but that doesn't mean I have to like it :-) This is the point I am trying to make about matching generic delegate types to handlers; I can see unwanted complexity about to rear its ugly head :-( I must admit that things like this have always put me off Pascal from before I ever saw Delphi; it was only the superb Delphi IDE that "encouraged" me to use Pascal in the first place. ... public class MyClass<typeT>: MyClass ...
    (borland.public.delphi.non-technical)
  • Re: C++ to Delphi, HELP !!!
    ... I think this is a Delphi implementation of the BluffTitler C++ ... PtrData: PCopyDataStruct; ...
    (alt.comp.lang.borland-delphi)
  • Re: C++ to Delphi, HELP !!!
    ... I think this is a Delphi implementation of the BluffTitler C++ ... PtrData: PCopyDataStruct; ...
    (alt.comp.lang.borland-delphi)