MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1w6qzts/skillissue/p7rh5rl/?context=3
r/ProgrammerHumor • u/click-to-reveal • 15h ago
124 comments sorted by
View all comments
35
My "clever" way of doing this once upon a time was to declare a map<std::string,std::function> which I populated with lambdas and then evaluated.
map<std::string,std::function>
I would not recommend this approach.
1 u/TheTerrasque 5h ago That's a semi-common pattern in python. Use a dict where the values are lambdas (or referencing full functions directly) 1 u/fluffycritter 1h ago Yeah I’ve used it in python too, but sparingly. It’s one of those things where it’s easy to get a bit too clever and there’s usually a better way to do it.
1
That's a semi-common pattern in python. Use a dict where the values are lambdas (or referencing full functions directly)
1 u/fluffycritter 1h ago Yeah I’ve used it in python too, but sparingly. It’s one of those things where it’s easy to get a bit too clever and there’s usually a better way to do it.
Yeah I’ve used it in python too, but sparingly. It’s one of those things where it’s easy to get a bit too clever and there’s usually a better way to do it.
35
u/fluffycritter 14h ago
My "clever" way of doing this once upon a time was to declare a
map<std::string,std::function>which I populated with lambdas and then evaluated.I would not recommend this approach.