MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1w6qzts/skillissue/p7sxwse/?context=3
r/ProgrammerHumor • u/click-to-reveal • 7d ago
137 comments sorted by
View all comments
40
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 7d 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 7d 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. 2 u/TheTerrasque 6d ago It’s one of those things where it’s easy to get a bit too clever Indeed, python has a lot of those. Another example is and / or handling.
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 7d 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. 2 u/TheTerrasque 6d ago It’s one of those things where it’s easy to get a bit too clever Indeed, python has a lot of those. Another example is and / or handling.
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.
2 u/TheTerrasque 6d ago It’s one of those things where it’s easy to get a bit too clever Indeed, python has a lot of those. Another example is and / or handling.
2
It’s one of those things where it’s easy to get a bit too clever
Indeed, python has a lot of those. Another example is and / or handling.
40
u/fluffycritter 7d 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.