leocharre has asked for the wisdom of the Perl Monks concerning the following question:
I've had some confusion about singleton objects and "scope"- of that object "instance".
I've seen stated that you can have only one instance of a singleton object- system wide. This is complete bs- right? A gross blanket statement.
It seems a singleton object is only good for the - how would you say this.. process? application instance? whatever first set your program in motion via the perl interpreter? The opening line here seems much more sensible.
If a singleton object were good system wide, it would mean that simply by calling use X, every process started by every user/non-user on that system shares the same access to the same data, (perhaps in memory in this case? or swap.. who knows). As I experience it- a singleton is not a one line daemon-ish hack.
I imagine the way to do this really- would be store the object instance in ram- even caching wouldn't do here- the technicalities are way beyond me.
So- could we get some clarification as to what a singleton really does as far as scope- where with an object, each is it's own thing- a singleton is the same thing as far as the current instance of your initial process/app instance is concerned, is this correct?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: what is the real scope of a singleton
by jeffa (Bishop) on Dec 23, 2008 at 15:25 UTC | |
by leocharre (Priest) on Dec 23, 2008 at 15:36 UTC | |
|
Re: what is the real scope of a singleton
by jdporter (Paladin) on Dec 23, 2008 at 19:15 UTC | |
|
Re: what is the real scope of a singleton
by chromatic (Archbishop) on Dec 23, 2008 at 19:12 UTC |