logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Class::Virtually::Abstract - Compile-time enforcement of Class::Virtual

Author

       Original idea and code from Ben Tilly's AbstractClass
       http://www.perlmonks.org/index.pl?node_id=44300&lastnode_id=45341

       Embraced and Extended by Michael G Schwern <schwern@pobox.com>

Bugs And Caveats

       Because this relies on import() it is important that your classes are used instead of required.  This is
       a problem, and I'm trying to figure a way around it.

       Also, if a subclass defines its own import() routine (I've done it) Class::Virtually::Abstract's compile-
       time checking is defeated.

       Got to think of a better way to do this besides import().

Description

       This subclass of Class::Virtual provides compile-time enforcement.  That means subclasses of your virtual
       class are required to implement all virtual methods or else it will not compile.

Name

       Class::Virtually::Abstract - Compile-time enforcement of Class::Virtual

See Also

       Class::Virtual

perl v5.34.0                                       2022-06-12                    Class::Virtually::Abstract(3pm)

Synopsis

         package My::Virtual::Idaho;
         use base qw(Class::Virtually::Abstract);

         __PACKAGE__->virtual_methods(qw(new foo bar this that));

         package My::Private::Idaho;
         use base qw(My::Virtual::Idaho);

         sub new { ... }
         sub foo { ... }
         sub bar { ... }
         sub this { ... }
         # oops, forgot to implement that()!!  Whatever will happen?!

         # Meanwhile, in another piece of code!
         # KA-BLAM!  My::Private::Idaho fails to compile because it didn't
         # fully implement My::Virtual::Idaho.
         use My::Private::Idaho;

See Also