3 ms·
No, even IORef is stateless. You will know if there's state in a language if you can build a function that returns different results given the same values over
by innguest 12y ago
No, even IORef is stateless.
You will know if there's state in a language if you can build a function that returns different results given the same values over time; IORef does not allow you to do that.
- dllthomas 12y agoThe bit that I was intending to modify was your statement that "in FP changes in RAM are incidental and the programmer need not manage them". With IORef, changes in RAM are not incidental, and the programmer is explicitly managing them. If IORef isn't direct enough for you, substitute Ptr. The fact that it happens in the runtime system does not necessarily mean that it is incidental or that it does not need to be managed by the programmer. As to your broader claim here, I while I understand what you're getting at (and probably wouldn't have bothered responding, but for the above) I think it's most precise to say that IORef is an encoding of state. This does not have to mean that state gets updated by means of side effects.