Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^5: Creating dispatch table with variable in function name

by roboticus (Chancellor)
on Nov 23, 2017 at 16:46 UTC ( #1204155=note: print w/replies, xml ) Need Help??


in reply to Re^4: Creating dispatch table with variable in function name
in thread Creating dispatch table with variable in function name

dsheroh:

I'll call it slightly more virtuous than the map version, and my reasoning is this: I can use grep and find all references to the function(s). On the other hand, if your lookup keys were the same as the function names, it would be a wash IMHO.

Having said that, in my personal code, I generally use magical code in lots of places, including using map to build dispatch tables as you're doing. But for production code, a little less magic is appreciated when trying to locate things like function references.

Experimenting with techniques to reduce typing and improve clarity is one of the areas in programming that I find very fun. When we come up with interesting new ways to simplify/clarify some of the menial tasks, we can build new idioms and improve the overall programming experience.

...roboticus

When your only tool is a hammer, all problems look like your thumb.

  • Comment on Re^5: Creating dispatch table with variable in function name

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2020-06-01 05:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?