Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

create a CODE ref from a parse tree?

by perl5ever (Pilgrim)
on Sep 08, 2012 at 16:21 UTC ( #992502=perlquestion: print w/ replies, xml ) Need Help??
perl5ever has asked for the wisdom of the Perl Monks concerning the following question:

It is possible to create a CODE ref that is based on the _parse tree_ of another CODE ref?

Normally we create CODE refs by specifying the source code for the subroutine.

I would like to create a perl function which takes a CODE ref as input, accesses the parse tree of the CODE ref and creates a new sub by specifying what the new sub's parse tree should be. Also, the new parse tree could contain elements from the first sub's parse tree.

Is this possible?

SO link: http://stackoverflow.com/questions/12332046/create-a-perl-sub-by-specifying-its-parse-tree

Comment on create a CODE ref from a parse tree?
Re: create a CODE ref from a parse tree?
by Corion (Pope) on Sep 08, 2012 at 16:43 UTC
    If you want to customize a subroutine behaviour, pass it a callback (a subroutine reference). Perl has no macro expansion.
Re: create a CODE ref from a parse tree?
by chromatic (Archbishop) on Sep 08, 2012 at 17:12 UTC

    What do you mean by parse tree?

      That's a good question. I guess I would want whatever perl uses for the internal representation of the CODE ref.
Re: create a CODE ref from a parse tree?
by ig (Vicar) on Sep 08, 2012 at 19:45 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://992502]
Approved by davido
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2014-12-29 02:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (184 votes), past polls