4 ms·
> If an object contains mutable state, it is not referentially transparent. Why shouldn't an object contain mutable state? When solving a problem for which pur
by adwn 13y ago
> If an object contains mutable state, it is not referentially transparent.
Why shouldn't an object contain mutable state? When solving a problem for which pure, stateless programming is not suitable, where would you put state if not inside an object?
- chongli 13y agoIn an STM monad, or an ST monad, or even an IORef, or a core.async channel, or whatever. Functional languages have manifold approaches to state that do not require you to lose track of time. And that's the real key to understanding state, isn't it? Time.
- adwn 13y agoPlease do not drag this discussion to stateful vs. stateless programming. It's about OO, which is typically, in practice and in theory, associated with mutable state.
- chongli 13y agoFrom the original article: Refactoring to Functional–Why Class? This is a multi-part series on Refactoring to Functional Programming