Nothing in Perl that I know of will prevent you from inheriting from such an object.
Ehhh… it's actually pretty easy to do in Moose/Moo/Class::Tiny. I mean, it's not rocket science to work around, but this should do the job:
use v5.16; package Example::Phone { use Moo; has number => (is => 'ro', required => 1); sub call { ... } # Make final sub BUILD { my $self = shift; die(sprintf '%s is final; %s cannot inherit', __PACKAGE__, ref +($self)) unless ref($self) eq __PACKAGE__; } } package Example::Phone::Mobile { use Moo; extends 'Example::Phone'; sub send_sms { ... } } my $number1 = Example::Phone->new(number => 1); my $number2 = Example::Phone::Mobile->new(number => 2); # dies
In reply to Re^4: Perl OOP
by tobyink
in thread Perl OOP
by QueenSvetlana
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |