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: [email protected]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/