Tom Pledger wrote:
> Is it common OO programming practice to cast the elements of a
> same-interface-different-implementation list, so as to recover the
> original objects in full detail?
Hmm, that's a bit of gray area, I think. Conceptually speaking, if a
function is given a list of Shapes, it should only assume that they are
Shapes, not Squares, nor Circles, nor Rectangles, etc. However,
practically speaking, sometimes a function "knows" that a given Shape is
actually a Circle, so it is sometimes useful to "down-cast" to the
object's real type. (Refer to Run-Time Type Information in C++) In
untyped languages, like Smalltalk, it really doesn't matter. You can
invoke any method on any object. If the object doesn't know how to
handle the method call, you get a run-time exception.
> (*) The hypothetical preprocessor is up for a Banal Comment Award. ;-)
Actually, this segues well into the larger discussion of organizing Open
Source projects within the Haskell community. I'm sure this problem has
been thought of by more than one person and has already been "solved" a
couple of times over. However, I'll be gormed if I can find any
reference to any such effort on haskell.org. Fortunately, someone on
this list supplied a reference to Haskell++, whose ideas I'm in the
process of stealing. :)
- Michael Hobbs