David Brown wrote:
> Oddly enough, that aspect isn't what makes it OOP, and isn't even
> necessary.  In CLOS, the methods (generic functions) are not part of the
> class or the structure.  Classes have their slots and inheritance
> completely independently of generic functions.  It's actually much more
> powerful than most OOP languages because the programmer can add new methods
> to existing classes and systems.

This is a nice feature. If only Smalltalk, Objective-C, Ruby, Perl5&6,
Python, Lua, Self.... ;-)

In reality, this is pretty much a feature of dynamic languages, and it
is only unusual if you've primarily worked with static languages.

>> Mostly people list their favorite language features, regardless if
>> whether or not it is necessary.
>>
>>>   - organization, as you have mentioned.
>>
>> The *essential* one, I argue.
> 
> Except that there are languages that are widely considered OOP that don't
> do this (CLOS).

CLOS effectively does do this. Some people try to argue that generic
dispatch means that you aren't doing this, but they're just being silly. ;-)

> Perhaps inheritance is not essential to OOP either?

It isn't.

> Paul Graham, in ANSI Common Lisp, argues that the separation of classes and
> objects is merely an optimization, and not necessary.

If Paul says it, it must be true. ;-)

>>>   - Dynamic dispatch.  Probably the most important part.  Allows
>>> calls to
>>>     be generalized 
>>
>> C++ uses static dispatch by default, doesn't it? If you write a C++
>> program and never define a virtual function, is your code necessarily
>> not OO then?
> 
> Yes.

/me falls out of chair.

Sorry, just not the case.

> The static dispatch of C++ is an optimization where the programmer
> can specify the parts of the system that aren't OOP, and are basically just
> using the encapsulation support of the language.

You can argue about whether it is an optimization or not, but you can't
claim that use of virtual functions is a necessary requirement for one's
C++ code to demonstrate OOP. Virtual functions are simply a way to
achieve polymorphism (and not the only way in C++), which is not in and
of itself a requirement for OOP (although it is definitely a feature
"commonly found in OO languages".

>> I'm trying to think of an OO language that doesn't have *any* dynamic
>> dispatch, and failing, so I think you're right (and I also think this
>> falls out of "data + behavior").
>>
>> "Features of many OO languages" != "Features of OOP".
> 
> But features of languages not considered OOP does teach us something about
> what people consider essential to OOP.
> 
> An interesting point: Haskell does have polymorphic dynamic dispatch (they
> even call them classes).  But most do not consider it OOP because the
> inheritance has to be done manually.

That's really a matter of perspective. I find it useful to look at what
is different between Haskell and O'Haskell. The O'Haskell folks seem to
think both subtyping *and* monadic objects were necessary. Given that
some "OO languages" don't have subtyping, it would seem to imply that
monadic objects were the key bit that is missing. Of course, such
reasoning works on the assumption that the O'Haskell folks are the
arbiters or what is and isn't an OO language, which is perhaps a bit of
a stretch, as none of them is named Alan Kay. ;-)

Seriously though: "OO language" != "OO programming".

--Chris

-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to