Package::Data::Inheritable

Package::Data::Inheritable contains inheritable and overridable package data/variables.
Download

Package::Data::Inheritable Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Giacomo Cerrai
  • Publisher web site:
  • http://search.cpan.org/~gcerrai/Package-Data-Inheritable-0.05/lib/Package/Data/Inheritable.pm

Package::Data::Inheritable Tags


Package::Data::Inheritable Description

Package::Data::Inheritable contains inheritable and overridable package data/variables. Package::Data::Inheritable contains inheritable and overridable package data/variables.SYNOPSIS use strict; package Base; use base qw( Package::Data::Inheritable ); BEGIN { Base->pkg_inheritable('$foo' => 'a not so ordinary package variable'); } print $foo; package Derived; use base qw( Base ); BEGIN { Derived->pkg_inheritable('$bar'); Derived->pkg_inheritable('@baz' => ); inherit Base; } print $foo, @baz, $bar;This module tries to deliver inheritable package data (variables) with a reasonably convenient interface. After declaration the variables can be used like ordinary package variables. Most importantly, these variables can be inherited by derived classes (packages) by calling the inherit() method. If a derived class doesn't call inherit() it will still be able to define its variables and make them inheritable by its subclasses. Scalar variables can be declared constant.Within your class (hierarchy) code you will benefit from compiler checks on those variables. The overall result is close to real class data members. Of course you can wrap your variables in accessor/mutators methods as you need.The semantic provided mimics the class data members in languages like C++ and Java. When you assign to an inherited variable within a derived class, every class in the inheritance hierarchy will see the new value. If you want to override a variable you must redeclare it explicitly.To declare inheritable variables two interfaces are provided: a method interface via pkg_inheritable() and pkg_const_inheritable(). an Exporter-like interface, via the array @EXPORT_INHERIT.Inheriting always requires invoking the inherit() method. The variable visibility (scope) depends on the interface you used. If you use the Exporter-like interface, variables will be declared via our, while if you use the method interface it will be like you had imported those variables. The Exporter like interface does not currently support constants.Requirements:· Perl Requirements: · Perl


Package::Data::Inheritable Related Software