[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]

Triggers and infinite loops



Trying as much as I can, I cannot find a solution for this.

Triggers (at the moment, cursor triggers are what I want to implement,
but it applies to triggers in general), that is callbacks when the
structure changes, need to be implemented in a way that makes sure they
don't go into infinite loops. Like, if a cursor trigger of the right
view's cursor moves the left view's cursor, and unexpectedly the two are
bound together by d.cursor-cargo.

Obviously, it would be nice to have a loop detector which is called with
the cell that triggers a trigger. When the triggers go into a loop, it
should be able to detect it, right? But then, ZZCursorReal.set doesn't
require to be given a loop detector instance, and ZZCursorReal.set is
the method that will cause the cursor triggers.

What about this: When we trigger something, we synchronize the space and
set a GLOBAL variable to a loop detector instance (if it isn't already
set, meaning we've been triggered by somebody else). This one's called
each time something is triggered. When we go into a loop, it throws an
error.

We just need to take care that these errors don't destroy something
vital. Thus every time we move a cursor we have to put in try...finally
if an error could mess something up?

Not nice, but what are the alternatives?

Or should we forget about this at the moment, as we gonna have them
cursors on a path from other cursors (as you said, Tuomas)?

Anyway, we need a solution for this because I want to have content &
general triggers at some point, too.

-b.