On Wed, Jan 18, 2006 at 01:56:53PM -0500, Rob Kinyon wrote:
: Today on #perl6, Audrey, Stevan and I were talking about $repr. A
: tangent arose where Audrey said that the difference between class
: methods and instance methods was simply whether or not the body
: contained an attribute access.
: 
: Is this true? If it is, then I think it violates polymorphism as
: demonstrated by the following:
: 
: class Dog {
:     method tail { "brown and short" }
: };
: 
: class Chihuahua is Dog {
:     has $.color;
:     method tail { $.color _ " and short" }
: };
: 
: You can say Dog.tail, Dog.new.tail, Chihuahua.new.tail, but not
: Chihuahua.tail. That's extremely counter-intuitive.

I don't think it's counterintuitive.  You've defined Dog with an
invariant .tail but not Chihuahua.  It's doing exactly what you asked
for under a prototype view of reality.

: I think that class methods should be explicitly defined as class
: methods and you cannot call a class method upon an instance, just as
: you cannot call an instance method upon a class. Plus, this should be
: determinable (for the most part) at compile time, which is a bonus,
: imho.

I believe this is already determinble at compile time for the most part.

But I have a strong gut-feeling that over the long term it's going to
be important to be able to view a given object as either a partially
instantiated class or a partially undefined object, and for that we have
to break down the false class/instance dichotomy.  And to the extent
that the dichotomy *isn't* false, we're trying to sweep classness into
the .meta object, which is the *real* class object in Perl 6.

Larry

Reply via email to