C
Chris Angelico
I don't know if I want to step into the flames here, but my understandinghas always been that in the absence of polymorphism the best you can do is"object based" programming instead of "object oriented" programming.
Object oriented programming takes things further, most significantly by introducing the idea that the object reference you are referencing might be a run time dependent sub-class. Even Python, which isn't strongly typed, manages polymorphism by allowing the self argument to a sub-class of the method class.
What you've said here is that "without polymorphism, you can't have
polymorphism".
The OS/2 PM with SOM (System Object Model) classes does give
polymorphic functionality; here's a bit of an example:
(Reference: http://www.markcrocker.com/rexxtipsntricks/rxtt28.2.0299.html
- class hierarchy, standard classes only)
Part way down you'll see WPFolder. It's a subclass of WPFileSystem
(aka "stuff backed by the disk" as opposed to abstract objects), which
is a subclass of WPObject (aka "stuff you can see and click on"),
which is a subclass of SOMObject (aka "stuff"). The WPFolder class
defines a whole pile of functionality, and its code is all stored in
some library somewhere, as a binary on the disk. Well and good.
Now look at the WPRootFolder class. It's a subclass of WPFolder and
adds a few extra bits and bobs designed for the root of any particular
drive (OS/2 uses an MS-DOS style of drive letters for volumes, rather
than a Unix-style mount points) - menu items for formatting the drive,
getting extra info perhaps, whatever. But most of its functionality
comes from WPFolder.
When a WPFolder method is called on a WPRootFolder, the code has to
handle the fact that it's working with a subclass of that object. As
long as the proper SOM boilerplate is maintained correctly, the
WPFolder code won't even be aware that it's operating on a
WPRootFolder. That's polymorphism, and it's all done in a completely
cross-language way
(There are additional complications, as it's possible for a subclass
to WPReplaceClass (I'm probably misremembering the function name)
itself into the position of the parent class, which messes up the
hierarchy a bit - it still all works, but it's less clean to describe.
Most things work the way I'm describing.)
ChrisA