develooper Front page | perl.perl6.language | Postings from June 2001

Per-object inheritance in core a red herring?

Thread Next
Michael G Schwern
June 28, 2001 19:32
Per-object inheritance in core a red herring?
Message ID:
"You are to chop down the largest tree in the forest wiiiiith... A HERRING!"

I've been following this whole per-object inheritance thing, .ISA,
etc... and one thing keeps coming to mind.

Why does this have to be in the core language?

First, its a relatively obscure feature.  Per-object inheritance isn't
something most people even know about much less can think of a good
way to use.  Before the Self crowd carves me up for dog food, it
doesn't mean its not an interesting and useful feature, it means its
unlikely to get used much.  Compared to, say, threading.

Second, and perhaps more importantly, we can do this perfectly well
with a module.  No hacks, no tricks, no filters.  Class::Classless is
one implementation (complete, but a little convoluted), Class::Object
is another (cleaner, but not complete yet).

Class::Object uses the mini-class technique (ie. auto-generated
classes that aren't much more than an @ISA and a place to stick
methods) which is fine.  In fact, its wonderfully elegant!  Since they
work entirely within perl's OO system *without* an autoloader, they're
just as efficient as any other object.  Object inheritance can be
gotten simply by manipulating @{ref $obj.'::ISA'} (encapsulated, of
course).  One class, one object.  It works, its efficient, it uses
existing syntax.

The rule of thumb has always been if you can do it in a module, don't
put it in the core.  Well, we can do it in a module.  Work on the
module, don't complicate the core.

PS It also means we don't have to wait two years for Perl 6 to be able
to use it!

PPS A Class::Object proof-of-concept is en route to CPAN. if its not
there yet.


Michael G. Schwern   <>
Perl6 Quality Assurance     <>	     Kwalitee Is Job One
List context isn't dangerous.  Misquoting Gibson is dangerous.
	-- Ziggy

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About