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

Re: Setting the Compiled Name by Hand

Thread Previous | Thread Next
From:
Nick Ing-Simmons
Date:
October 2, 2003 04:24
Subject:
Re: Setting the Compiled Name by Hand
Message ID:
20031002112406.2481.4@llama.elixent.com
Martyn J. Pearce <fluffy@sixears.co.uk> writes:
>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).

So what do you want to see there?
I ask as when closures are involved faking things up is more tricky.

>So my questions are:
>
>1) Am I missing a pure perl option?
>
>2) Am I right to think that it is possible with XS?

XS bcomes C code, perl core is C code - anything core can do XS can do.
Downside is that sometimes you have to know a lot more about internals
than is otherwise necessary, documented or stable.

>
>3) Can you please give me a pointer as to where to start?

Look at code that debugger/profiler uses to print the problem string and 
figure out what slot of what needs to get changed.
You may be in trouble though - the "name" usually comes from the GV 
(glob) and you may not have (a unique) one. So then you need to start 
creating them and hooking them into other data structures - if you 
don't get that "right" you may get cores.




Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About