Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Re: A module to merge packages

by dakkar (Hermit)
on Jun 26, 2002 at 13:55 UTC ( [id://177383]=note: print w/replies, xml ) Need Help??


in reply to Re: A module to merge packages
in thread A module to merge packages

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://177383]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-23 18:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found