in reply to The costs of packages

Is there any real need to use classes at all? You could just use one class and store the information which C-class it is for inside.

example:

package My::Types; sub new { my $pclass = shift; my $cclass = shift; my $cself = $pclass->readFromData($cclass); my $pself = { cself => $cself, cclass => $cclass }; return bless $pself, ref($pclass)||$pclass; } sub isSame { my $pclass = shift; my $other = shift; return undef unless $other->CORE::isa(__PACKAGE__); return $other->{cclass} eq $pself->{cclass}; } sub getNumberOfParams { my $pself = shift; my $cself = $pself->{cself}; return $cself->{noOfParm}; } ... package main; $a = My::Types->new('printf'); print $a->getNumberOfParams();
(untested code)

Update: Oops, I coded an isSame() method, not an isa(). Renamed it to avoid misunderstandings...