Take me over?
NAME
foundation - Inheritance without objects
SYNOPSIS
package
Foo;
sub
fooble { 42 }
package
Bar;
sub
mooble { 23 }
sub
hooble { 13 }
package
FooBar;
use
foundation;
foundation(
qw(Foo Bar)
);
sub
hooble { 31 }
fooble();
# prints 42
moodle();
# prints 23
hooble();
# prints 31 (FooBar overrides hooble() from Bar)
SUPER(
'hooble'
);
# prints 13 (Bar's hooble())
DESCRIPTION
Haven't drunk the OO Kool-Aid yet? Think object-oriented has something to do with Ayn Rand? Do you eat Java programmers for breakfast?
If the answer to any of those is yes, than this is the module for you! foundation
adds the power of inheritance without getting into a class-war!
Simply use foundation
and list which libraries symbols you wish to "inherit". It then sucks in all the symbols from those libraries into the current one.
Functions
- foundation
-
foundation(
@libraries
);
Declares what libraries you are founded on. Similar to
use base
. - SUPER
-
my
@results
= SUPER(
$function
,
@args
);
Calls the named $function of the current package's foundation with the given @args.
Similar to
$obj-
SUPER::meth();>
BUGS
Plenty, I'm sure. This is a quick proof-of-concept knock off.
AUTHOR
Michael G Schwern <schwern@pobox.com>
SEE ALSO
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 129:
You forgot a '=back' before '=head1'