[OT] Perl OO Question.

Peter Corlett abuse at cabal.org.uk
Thu Oct 5 18:01:41 BST 2006

On Thu, Oct 05, 2006 at 05:10:20PM +0100, McGlinchy, Alistair wrote:
> Surely a call to MainframeFile->new() must return a MainframeFile object;
> or is it ok to return a subclass of MainframeFile?

You can return *anything*, although you should ensure that it at least
*looks* like it's the same kind of object and implements the same API, not
for Perl's sake but the sanity of the user of the class.

Whether you use inheritance or duck typing to present the API is down to
you. The implementation of tied variables is an example of duck typing.

(Duck typing is where you don't actually subclass a type, just implement its
API. It's interchangable with the real thing in languages like Perl and

More information about the london.pm mailing list