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

Per-object inheritance in core a red herring?

Thread Next
From:
Michael G Schwern
Date:
June 28, 2001 19:32
Subject:
Per-object inheritance in core a red herring?
Message ID:
20010628223253.B23259@blackrider
"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.
http://www.pobox.com/~schwern/src/Class-Object-0.01.tar.gz if its not
there yet.

-- 

Michael G. Schwern   <schwern@pobox.com>    http://www.pobox.com/~schwern/
Perl6 Quality Assurance     <perl-qa@perl.org>	     Kwalitee Is Job One
List context isn't dangerous.  Misquoting Gibson is dangerous.
	-- Ziggy

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About