Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: How to get function's name inside of CODE attribute (monkey see)

by tye (Cardinal)
on Oct 05, 2011 at 18:40 UTC ( #929851=note: print w/ replies, xml ) Need Help??


in reply to Re: How to get function's name inside of CODE attribute
in thread How to get function's name inside of CODE attribute

I added in Attribute::Lexical to avoid the need to monkeypatch UNIVERSAL.

You don't have to read much of the code before you get to:

unshift @UNIVERSAL::ISA, "Attribute::Lexical::UNIVERSAL";

So, this module avoids adding methods to UNIVERSAL (I assume), but adding a super class after the fact is certainly also monkey patching.

(Yes, I actually implement attributes without monkey patching UNIVERSAL at all and much more simply and, IMHO, sanely and buttoning that up for CPAN is on my to-do list.)

- tye        


Comment on Re^2: How to get function's name inside of CODE attribute (monkey see)
Download Code
Re^3: How to get function's name inside of CODE attribute (monkey see)
by stvn (Monsignor) on Oct 05, 2011 at 19:29 UTC
    Yes, I actually implement attributes without monkey patching UNIVERSAL at all and much more simply and, IMHO, sanely and buttoning that up for CPAN is on my to-do list.

    Is the code sane enough for github? or some other public code hosting site? I would like to see this.

    -stvn

      Actually, much of the code is included in Devel::Init. After the __END__ line is even the code I decided to leave out of Devel::Init that tries to provide compatibility with the first entrant, Attribute::Handlers.

      No, Devel::Init is not a tool for enabling developers to easily define their own attributes. But the code in Devel::Init only requires small additions and minor reworking for it to become that.

      - tye        

Re^3: How to get function's name inside of CODE attribute
by chromatic (Archbishop) on Oct 05, 2011 at 20:06 UTC

    I'm no fan of that myself, but it's less troublesome than putting all handlers in UNIVERSAL. I'll happily switch to a better solution that avoids modifying global behavior altogether.


    Improve your skills with Modern Perl: the free book.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2015-07-05 05:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls