I know of Schwern's Sex, but what the two modules do is different.
My Merge creates a package whose @ISA is a list I specify.
Sex creates a package by mixing up symbol table entries, both subs and variables, and (by the way) pushing the "parents" into the "child"'s @ISA.
My first solution was a simplification of Sex (with less error checking, no schwernian messages, and no randomness), but it creates problem with classes, and makes it impossible to use NEXT to add functionality to a method, in something like:
package a;
sub method {
my $self=shift;
# do something
}
package b;
use NEXT;
sub method {
my $self=shift;
# do something before
$self->NEXT::method(@_); # do the normal stuff
# do something after
}
package main;
require a;require b;
use Merge qw(b a)=>'c';
$c=new c;$c->method; # will call "b"'s implemetation, which will call
+"a"'s via NEXT
|