Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: add method at runtime

by LanX (Canon)
on Jan 29, 2013 at 17:23 UTC ( #1015911=note: print w/ replies, xml ) Need Help??


in reply to add method at runtime

> Hi is it possible to add methods and properties at runtime,like in Python?

Yes, semantically pretty much the same way.

For instance see Re: change perl function in runtime

> and why would there be need to do that,why is that an advantage anyway?

Monkey patching is a way for module users to dynamically adjust foreign modules to their temporary needs w/o changing the installed and officially maintained code.

UPDATE

Ah roboticus did good in mentioning Autoloading. It's a technique for module authors (not module users) who want to decide to compile functions only on demand.

(For instance this can improve compile/load time. IIRC does (did?) CGI.pm something comparable.)

Cheers Rolf


Comment on Re: add method at runtime

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (19)
As of 2015-07-29 13:56 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 (263 votes), past polls