O'Reilly logo
  • Mashrur Mia thinks this is interesting:

We could choose to destructively modify the current environment instead of making a new one, but avoiding destructive updates forces us to make the consequences of #reduce completely explicit. If #reduce wants to change the current environment, it has to communicate that by returning an updated environment to its caller; conversely, if it doesn’t return an environment, we can be sure it hasn’t made any changes.


Cover of Understanding Computation


To indicate that #reduce does affect an environment (has a side effect), it is to return the a new merged environment, keeping the old environment untouched.

if we were to change the old environment, then no return was needed. But then we cannot convey that an environment was affected and see by return that an environment was changed.

Basically, if a reduction does not return an environment, we can be sure that the environment was not changed.