Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: dynamic method creation, dispatch table or pseudo methods?

by perlfan (Vicar)
on Apr 19, 2021 at 00:51 UTC ( #11131451=note: print w/replies, xml ) Need Help??

in reply to dynamic method creation, dispatch table or pseudo methods?

> should I add Some::Mod to prerequisites

Since you're using require, this would not effect any installation process. But it'll be a run time error. So if you wish to be "kind" to your users, then yes you should add it. If there is a core feature set you can provide and put any of the commands that will never be loaded into extension modules. And in those, make sure you have full coverage of the modules needed.

As for the first part of your question, if you got something work it, go for it. I will say, the whole time I was reading this I kept thinking App::Cmd. I cast no judgement personally regarding the various ways Perl allows for the dynamic creation of subs. I've used only a fraction in my day, but always enjoy seeing the options laid out. However, I will answer the question with a question: do you really need to allow users to define custom commands in that way? It seems like you're looking for a perl REPL/shell - and I think a few options exist. So your question may come down to - which one to use and how do I want to extend it to provide custom commands.

  • Comment on Re: dynamic method creation, dispatch table or pseudo methods?

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2021-10-18 05:26 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (72 votes). Check out past polls.