in reply to Re: Polymorphism in Perl
in thread Polymorphism in Perl
You don't need inheritance (much less method overriding) for polymorphism in Perl. You can just use duck typing, where you design an interface that consists of one or more method calls and then any object or class that implements that interface can be passed to code that makes use of that interface.
Note that Perl itself doesn't provide a way to declare "interfaces" so when I say "design an interface", I'm talking about documentation for humans not coding. Though, languages like C++ and Java that support declaring an interface don't actually express interfaces fully, of course, so designing an interface there should also involve documentation for humans, not just writing a bunch of method signatures.
- tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Polymorphism in Perl (interface)
by SuicideJunkie (Vicar) on Feb 07, 2011 at 22:05 UTC |