[oak perl] (fwd) How Perl Powers Christmas

Belden Lyman blyman at iii.com
Thu Dec 19 15:45:24 CST 2002


Belden Lyman wrote:
 >
 > use Bill::Gates qw(unholy_trade_practices); # Bill::Gates not OO :(
 >

Obviously the Bill::Gates module can't be Object-Oriented. This is
because in Perl, variables are made into objects by C<bless>-ing them
into a C<package>. First, Bill::Gates most likey does not have a
proper C<package>; even if a C<package> existed, the function
&unholy_trade_practices() is not convertible into a method that a
C<bless>-ed object can use.

> 
> my $market = new Tech::Sector; # singleton class, this sucks :(
> 

A singleton class is one that, no matter how many times you ask
it to create a new object, will just keep returning the same object
back to you.

The reason a singleton Tech::Sector sucks should therefore be obvious:
if someone were to patch Tech::Sector.pm to allow multiple market
objects to be created, then we could run a multi-process simulation to
figure out the best environment for a healthy Tech::Sector.

Belden




More information about the Oakland mailing list