4 ms·
> How do you pass a member identification as a parameter to a function that may receive any kind of structure, and then update that member? You don't. You just
by atilaneves 8y ago
> How do you pass a member identification as a parameter to a function that may receive any kind of structure, and then update that member?
You don't. You just update that member.
- marcosdumay 8y agoSo, no generics available (templates are an option, but way to troublesome to use for that). That aligns with my experience, but mine is currently out of date, thus the question.
- atilaneves 8y agoThe main takeaway is that this isn't necessary with mutable structures. Nobody would think of even trying to write a generic solution to a problem that doesn't exist in C++.
- marcosdumay 8y agoLens are about composition and abstracting your operations over unknown structures. I don't know where did you find anything about immutability, as plain data accessors are perfectly fine for that. The motivation on the article is basically this paragraph: "Lenses allow you to abstract state shape behind getters and setters. Instead of littering your codebase with code that dives deep into the shape of a particular object, import a lens. If you later need to change the state shape, you can do so in the lens, and none of the code that depends on the lens will need to change." Immutability does not make its way there.