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

Re^2: Dynamically generate setter/getter methods [Updated]

by pryrt (Abbot)
on Dec 20, 2020 at 21:54 UTC ( [id://11125510]=note: print w/replies, xml ) Need Help??


in reply to Re: Dynamically generate setter/getter methods [Updated]
in thread Dynamically generate setter/getter methods

I learned and used the AUTOLOAD methodolgy for the first time when I was developing the Editor component for Win32::Mechanize::NotepadPlusPlus.

For that, I was mapping a pre-defined list of function prototypes I was stealing from drawing on from the API for a Notepad++ plugin which used some other language for automating Notepad++, and mapping those prototypes to the underlying Windows messages for the Scintilla component of Notepad++; there were about 10 common mappings from function requirements to message requirements. So, when I saw I had hundreds (over a thousand, I think but I didn't re-count) of functions which were just going to follow the same 10 or so patterns, I wanted to obey DRY, so decided I had to finally figure out what AUTOLOAD was, and whether it would help me.

If AUTOLOAD hadn't done what I wanted, I would have just manipulated the symbol table myself... but since AUTOLOAD was a feature of Perl that I hadn't explored, I wanted to see if I could make it work. In the end, AUTOLOAD wasn't that hard for me to learn, and it accomplished my goal pretty handily.

I wouldn't call myself an AUTOLOAD expert, nor do I know all the times when it's benefits would really shine, but I found it a useful tool -- and now I have an example implementation that I should theoretically understand a few years down the road, the next time I want to try to AUTOLOAD.

  • Comment on Re^2: Dynamically generate setter/getter methods [Updated]

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-26 01:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found