On Mon, 7 Oct 2002, Andy Wardley wrote: : Nicholas Clark wrote: : > I think that the first syntax : > : > class Car::Q is Car renames(eject => ejector_seat) : > is CD_Player renames(drive => cd_drive); : > : > makes it more clear that I'd like to pick and choose which methods : > the composite object gets from which parent. : : But now you've turned composition back into inheritance, and I think it's : important to be able to distinguish between the two. : : The car is definately not a CD player, it just has one. : : I think we need a more flexible syntax for specifying how interfaces : should be constructed in the case of composed objects, rather than : turning composition into inheritance to avoid the problem.
Yes, that's important. If you've got a CD_Player *object*, it doesn't do anyone any good to pretend it's a car *object*. We too often lose sight of the fact that objects should behave like objects. That's what OO really means, after all. OO isn't about inheritance Anyway, I don't see offhand why composition can't simply be done with attributes as it is in C++, especially since attributes manifest as methods outside the class. I don't think $car.cd.eject() is all that horrible to contemplate. Larry