[fpc-pascal] Implementing a true Singleton - Can we decrease the visibility of a method?
graemeg.lists at gmail.com
Fri Dec 8 10:55:02 CET 2006
On 12/8/06, Vincent Snijders <vsnijders at quicknet.nl> wrote:
> I think the solution is to create a public constructor which throws an
> NotImplemented exception or something like that.
Ok, that works, or at least stops a developer from trying to create a
instance directly. In the exception message, I mention the correct
function they should have used.
> Note: instead of making function GetSingleton : TSingleton; a global function you
> could make it class function GetInstance too.
Yes I know, thanks. But I prefer to use the function, as it is less
typing, especially when the class name is lengthy. I also normally
prefix it with a 'g' to show it is a global singleton function.
When you use singletons a lot (as I do), less typing is better. :)
I still don't know why we can't decrease visibility in Free Pascal.
Is there some internal language design that prevents it?
There's no place like S34° 03.168' E018° 49.342'
More information about the fpc-pascal