Why would frameCount++ increment by 2?

In playing with some animation code I noticed that inside a generator the post increment operator seems to increment the value twice. The is demonstrated in this notebook
Iy is not really a problem since the workaround is trivial (val = val + 1; ) but it worries me because I don’t understand it.

I can’t quite see the problem, but it’s probably caused by this line

    mutable frameCount = frameCount + 1;

which should read

    mutable frameCount = mutable frameCount + 1;

By referencing frameCount instead of mutable frameCount the cell invalidates whenever the mutable's value changes.


Yep, what @mootari said. In general you never want to reference x in the same cell that you assign to mutable x because it will cause an (asynchronous) infinite loop.

I understand now. Thank you.