Subject: | caller() can take an arg, you know |
it seems that Acme::Dot does not need to clobber the caller's import
function in order to determine
$call_pack2 = (caller(1))[0]
furthermore, clobbering call_pack2's AUTOLOAD seems clumsy. Acme::Dot
works by creating an AUTOLOAD in the outer using package that catches
unknown method calls and returns objects that make sense to the
routine that dot has been overloaded to.
we could do this without replacing AUTOLOAD by polluting the outer
package with many little functions that the dot-handler can take for each
of the dot-invocable methods. The list of methods could be made arguments
to Use Dot or the list of methods could be determined by analyzing the
symbol table in a CHECK block or in a wrapper to the caller's import.
furthermore we can't Use Dot in multiple modules and have them all work
since the CHECK block would only run with regard to one of them, so
a wrapper to the caller's import might be the way to go. Something like
sub Dot::import{
...
eval "package $call_pack;\n".<<'EOF';
CHECK {
my $pollute = sub {
make a bunch of method in caller(1)'s namespace
};
if (defined (&import)){
my $orig_import = \&import;
*import = sub {
$pollute();
goto &$orig_import ;
}
}else{
*import = sub {
$pollute();
}
}
}
EOF
The collision modes between methods, that have to get exported because
of dot, and functions in the using package, does not appear resolvable.
Using object dispatch within the overload handler means that multiple
packages that dot-export methods with the same names will not be a
problem.
thanks