GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Class::Virtually::Abstract(3) User Contributed Perl Documentation Class::Virtually::Abstract(3)

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

  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;

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.

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().

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>

Class::Virtual
2016-08-06 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.