develooper Front page | perl.perl5.porters | Postings from October 2003

Re: Setting the Compiled Name by Hand

Thread Previous | Thread Next
Slaven Rezic
October 2, 2003 02:36
Re: Setting the Compiled Name by Hand
Message ID:
"Martyn J. Pearce" <> wrote:
> Greetings Porters,
> I have a slightly unusual(?) requirement with Perl/XS that you may be able to
> help with.
> In the Class::MethodMaker module that I maintain, methods are created on the
> fly and inserted into the clients namespace using a glob assignment from an
> anonymous coderef (that may or may not be a closure).
> The issue is that when debugging or profiling, all such methods are referred
> to as 'Class::MethodMaker::__ANON__', because that's where the code is
> compiled.  The only Perl method I can think of around would involve string
> evals, which are unnacceptably slow (and lose an element of compile-time
> checking).
> However, I figure that it must be possible to reset the relevant name with a
> little XS code.  Unfortunately, I'm very much into uncharted waters (for me)
> here.
> So my questions are:
> 1) Am I missing a pure perl option?
> 2) Am I right to think that it is possible with XS?
> 3) Can you please give me a pointer as to where to start?
> Obviously complete solutions are welcome too, but I don't want to be *too*
> presumptious... :-)

Try to set the $DB::sub variable:

    my $sub = sub {
        $DB::sub = "namedsub";


Slaven Rezic - slaven <at> rezic <dot> de

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About