Re: Naive, possibly silly question

From: Dave Harris (brangdon_at_cix.co.uk)
Date: 10/31/03


Date: Fri, 31 Oct 2003 21:27 +0000 (GMT Standard Time)

mfeathers@objectmentorNOSPAM.com (Michael Feathers) wrote (abridged):
> There is a statically typed prototype-based language called Omega, but
> even that uses inheritance to share behavior.

I am not sure what sharing behaviour has to do with type-checking or
message dispatch. They seem to be 3 different things, more or less
orthogonal.

> The root thing is that when you have a statically typed OO language, the
> compiler has to know whether an object can accept a particular message.
> So, every instance has to be traced back to a particular specification
> of behavior.

I am not sure what you mean here. What is the "particular specification of
behaviour" for something like:

    template <typename T> T max( T a, T b ) { return a > b ? a : b; }

It's just invoking operator<() and hoping it does the right thing.

> I wouldn't count C++ templates, they are an entirely different kind of
> polymorphism.

Well, yes, but there's no reason why in some hypothetical language
something like the above couldn't be dispatched at run-time, using a
mechanism like Smalltalk's. Is there?

> I can imagine a statically-typed OO language that didn't use
> inheritance or delegation mimicking inheritance, but it would be
> pretty silly. Each instance would be a type and it would
> have its own method definitions.

Again you seem to be confusing reuse of method definitions with type
checking and/or polymorphism.

-- Dave Harris, Nottingham, UK



Relevant Pages

  • Re: Advantages of object-oriented programming
    ... consider classes or inheritance to be a neccessary part of the ... while in a language that is not object-oriented it does not. ... In a object-oriented language, I write method definitions ... Is this the most important advantage of run-time polymorphism ...
    (comp.object)
  • Re: To understand OOP better...
    ... > could support dynamic polymorphism through the use of evil weakly-typed ... Polymorphism via inheritance is known as inclusion polymorphism. ... the way object responsibilities are defined (i.e., ... > BTW, encapsulation is deprecated. ...
    (comp.object)
  • Re: Basic Explaination of OO in Ada
    ... Programming by extension does not necessarily involve inheritance. ... package Pak2 is ... access types are not necessary to achieve polymorphism; ...
    (comp.lang.ada)
  • Re: On assembly and portability (between Linux and Windows)
    ... A short note on Object Oriented Programming (OOP). ... Inheritance is the ability to extend data structures by ... Polymorphism is the ability to override an existing ... oriented features. ...
    (alt.lang.asm)
  • Re: OOP/OOD Philosophy
    ... > related by inheritance, nor do they need to inherit from a common base ... example of polymorphism? ... >>Perhaps what you mean to say, is that those languages have additional ... >>> Smalltalk programmers do not depend upon inheritance to provide ...
    (comp.object)