The core issue here is that modification have no deeper order. E.g.
Consider cells like:
# cell 1
x = Ref(2)
# cell 2
x[] = 5
# cell 3
@show x
Then it is clear that cell 1 must be executed first becuase it defines the variable x
used in the other cells. But there is no unambigous order of cells 2 and 3.
You can introduce “auxiliary variables” to establish an order like:
# cell 1
x = Ref(2)
# cell 2
x[] = 5; aux=nothing;
# cell 3
aux; @show x