September 2019 Archives

Signatures vs. Methods

I've still been thinking about proper OO in the Perl core and hit an interesting case.

Imagine the following, hypothetical Perl 5 OO syntax. Inheritance is handled via is and inheritance order is assumed to parent class declaration order. Thus, UnlovedChild inherits from MissingFather first.

What do you think the output should be?

class MissingFather {
    method shout() { say "I'm outta here!" }

class DrunkenMother {
    method shout($message) { say "$message!" }

class UnlovedChild is MissingFather, DrunkenMother {}

UnlovedChild->shout("Where's my beer?!")

About Ovid

user-pic Freelance Perl/Testing/Agile consultant and trainer. See for our services. If you have a problem with Perl, we will solve it for you. And don't forget to buy my book!