4 ms·
The premise of immutability is that this causes bugs: doA() doB() doC() and so the solution is instead of doing: State state doA(&state)
by earthboundkid 5y ago
The premise of immutability is that this causes bugs:
doA()
doB()
doC()
and so the solution is instead of doing:
State state
doA(&state)
doB(&state)
doC(&state)
you do
State state
state2 = doA(state)
state3 = doB(state2)
state4 = doC(state3)
But obviously, the only difference between 2 and 3 is that 3 is a pain in the ass to type out. All of the benefit is there in 2 because you're explicitly declaring what it is that the functions are modifying, instead of having them modify unseen globals. There's no advantage to adding a ugly calling convention on top of that.