top | item 45768997

(no title)

pasteldream | 4 months ago

> Your natural choice in the "OOP style" is to write a lot of boiler plate to point to each different field you want to get/set.

Your natural alternative to lenses in imperative languages is usually to just store a reference or pointer to the part you want to modify. Like a lens, but in-place.

discuss

order

ForHackernews|4 months ago

But then you're modifying the thing, not creating a new object with different content. It's different semantics.

pasteldream|4 months ago

Yeah, but I’m saying that in 90% of the cases where a functional program would use lenses, the corresponding imperative program would just use references.