Perl Diver 2.33
Main Environment Variables Perl Default Values Perl Config - Summary Perl Config - Full Installed Modules List Directory uptime Docs

Module Documentation
Details and documentation about a specific module, including version and documentation (if available). Note that while links to perldoc.com and search.cpan.org are provided, the module may be part of a larger distribution. If you reach a File Not Found page on either site, please try the parent module.

Class::Virtually::Abstract

Name Class::Virtually::Abstract
Version 0.08
Located at /usr/share/perl5
File /usr/share/perl5/Class/Virtually/Abstract.pm
Is Core No
Search CPAN for this module Class::Virtually::Abstract
Documentation Class::Virtually::Abstract
Module Details Class::Virtually::Abstract


NAME

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


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;


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.


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


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>


SEE ALSO

the Class::Virtual manpage

Perl Diver brought to you by ScriptSolutions.com © 1997- 2026