in reply to A module to merge packages

There is already a module Sex which does what you do, and it's available as ActiveState installation package, and also exists on CPAN, version 0.69

Best wishes,
I.R.Baboon.

Replies are listed 'Best First'.
Re: Re: A module to merge packages
by dakkar (Hermit) on Jun 26, 2002 at 13:55 UTC

    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