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