Hi,
if I see it correctly the collision system already has a way to handle bond creation later, I think this could easily be extended to the other collision mode.
Also I think there are some low-hanging optimization fruits in this code is performance is an issue, like buffering the collision queue.
This of course also has state, but it is only limited to the method, so the collision code can only break its own stuff with it. I think the affinity could be
handled in the same way, and those are the only two features that actually change particles during the short-range force calculation.
Also modifying the particle state during calculation does not mix well with other parts of the code, for example there could be a copy of the particle configuration
on the GPU which then would be out of sync. The same goes for the system interface which promises that the state does not change during force calculation,
so that the order of the actors does not matter.
It is clear that there is some overhead in doing it like this, but I think the Espresso way clearly is to sacrifice a (probably rather small) bit of performance of a
single feature for for clarity and better code structure. Also you have to factor in the hours lost in development by bad code structure and in bug hunting into your performance
calculation. On a general note, I think the main reason why the Espresso code is in such a bad shape today is because total cost of ownership was never
factored into anything. And we should start to improve that gradually. (I am aware of the fact that there seems to be some dialectic in this paragraph.)
Cheers,
Florian