Okay, but now we're getting into the fundamental O-O model for
Perl.  I guess that's fair game?  You can certainly make the case
that prototype-based inheritance makes at least as much sense
as class-based inheritance for a dynamic language like Perl.
But that's a major implementation change and you have to be careful
to be sure that "Perl stays Perl".

As Mr. Porter wrote, you can have both types of inheritance.
If classes are just objects, which happen to be the prototype
of their instances, and superclasses are the prototype objects of their
subclasses, then you can have one simple inheritance model that
is really prototype-based but does a good job of acting like it's
class-based.  Especially if you provide syntactic constructs to
make it look that way.

Then in order to continue to support multiple inheritance, 
each object would have to have multiple prototypes.  Which would
automatically supply MI at the instance level as well as at the
class level, since instances and classes are really just slightly
different manifestations of the same thing.

But you're opening a big can of worms if you make such a 
change.  The biggest impact would be in the way methods are defined.  
Instead of just being members of a package, they would have to be
associated with particular objects (classes or instances).  A method
may still be associated with a class by being defined in its
package, but what about an instance?    Do we give each
instance a package?

You could go the Python/JavaScript route and have methods just
be members that happen to contain code references, so
$obj.meth(@args) would be a synonym for $obj.{meth}.(@args)
(or $obj{meth}(@args) with the optional '.'s elided). But then
you're merging two namespaces that used to be distinct; e.g.
how do you provide an accessor function with the same name as
the scalar attribute it's protecting?  

While I'm also fond of prototype-based inheritance, I think changing
the inhertiance model in Perl would be among the most radical
changes discussed so far.  Not to say it's not doable, but I'm
wondering if it  would be worth it or if it would really maintain the
language's fundamentally Perlish nature.

On Wed, Jun 27, 2001 at 02:25:04PM -0400, John Porter wrote:
> Dan Sugalski wrote:
> > * Objects are bigger since they all need an .ISA property, if we toss the 
> > per-class @ISA
> 
> I certainly like the idea of instance-level inheritance (since
> it's the only way to go in prototype-based OO), but I hope we
> wouldn't sacrifice class-level inheritance for it.
> We could have both, right?  We could let classes be first-class
> objects, eh?
> 
> -- 
> John Porter

-- 
Mark J. REED    <[EMAIL PROTECTED]>

Reply via email to