From what I understood, the main complaint against stateful closures (would that be what you call them) is when you provide it with the same inputs, and get different outputs. Any function should provide the same output for the same input, every time.
But, as you pointed out, constants don't contribute that issue.
From what I understood, the main complaint against stateful closures (would that be what you call them) is when you provide it with the same inputs, and get different outputs. Any function should provide the same output for the same input, every time.
But, as you pointed out, constants don't contribute that issue.
Closure without mutation or re-assignment ("pure"):
Closure with re-assignment
+=("not pure"):My point is that there is nothing wrong with closures. It is re-assignment and mutation which make closures (or functions) "not pure".
Yup, makes sense!
Re state: in pure FP I think we mean a "named" piece of data whose instances get changed over time:
Here
scan be thought of as state, even though specific bindings ofsdon't change.We observe state over the course of computation.