I understand that the difference is that, while neither may change the state, view
may read the state and pure
may not. I also understand that it's useful to distinguish possibly state-changing functions from those guaranteed not to change the state.
My question is, why is it useful to indicate that a function won't even access state? Why doesn't view
suffice?
pure
functions. And by the way, you could just as well ask the same question aboutview
(i.e., why is it useful to indicate that a function won't change state?).pure
function, you "remind" yourself (and others), that this function has no intention of reading state variables, nor to invoke any other function which reads state variables. It's kinda likeconst
in C/C++. If you later decide to change functionality, you get this compilation error reminding you of your original design intentions.