No, polymorphism doesn't depend on inheritance, and I never claimed that it did. Polymorphism is generally an expected outcome of inheritance though. There are clearly other ways of allowing polymorphism though - roles as you say; also mocking, delegation, etc.
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
| [reply] |
From the POD:
The idea behind polymorphism is that if Bar inherits from Foo, then I should be able to use an object of type Bar wherever I'd normally use Foo.
That makes it sound like you're equating polymorphism with inheritance.
| [reply] |