A global is something that is in the global namespace. A singleton isn't, any more than other class is. You have to import the class to which it belongs to use it.
Noone mentioned making the *stream* a singleton. I'd expect to find teh *stream* at OS level. It's just that an audio *player* is a better example of something that you might want to be assured that there can only be one *instance* of. Until someone actually presents a solid reason why you should *never* have a class which can only have a single instance, the argument is going nowhere, as far as I can see. (apologies for polluting the list with this rather OT stuff ...) On 11/17/06, Adam Clarke <[EMAIL PROTECTED]> wrote:
On 17/11/2006, at 4:37 PM, Jonathan Rockway wrote: > On Thursday 16 November 2006 20:08, A. Pagaltzis wrote: >> A singleton is nothing but a global variable, except the >> identifier comes from the class namespace rather than the >> variable namespace. Put it in a global variable already. > > Not entirely true. Try this: > > $global = "Oops, accidentally overwrote the instance with garbage."; > > vs. > > Singleton->get_instance() = "Oops, accidentally overwrote the > instance."; Not really, because ... use Readonly; Readonly my $global => "Warming"; print "Before => $global\n\n"; eval { $global = "Oops, accidentally overwrote the instance with garbage."; }; if ($@) { print "Error (would have died if uneval'd) => [EMAIL PROTECTED]"; }; print "After => $global\n"; produces ... Before => Warming Error (would have died if uneval'd) => Modification of a read- only value attempted at t.pl line 8 After => Warming No matter what my prime minister says. Cheers -- Adam Clarke www.strategicdata.com.au _______________________________________________ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
-- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 _______________________________________________ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/