dunbarx wrote:I still do not quite see the nesting you speak of. Rather, like a line of code that "sends" a message to another handler, (where I do believe there is a true branch out of the calling handler), I thought of the structure of Simon's first script similarly, that the recall to "mouseUp" branched out of itself, and did not nest itself, er, within itself.
We may be talking about the same thing, but I see it more like nesting. If you substitute a different handler name for the nested "mouseup" it might be more clear. When a mouseup calls another handler, the second handler executes and then control returns to the mouseup, which then finishes. The same thing happens here -- only the "second" handler is a call to itself.
When that happens, each self-call "nests" inside the original. The remainder of the previous mouseup(s) are suspended while the "inside" ones finish. As each completes, the one that called it will resume execution and complete, and then the one that called
that one completes, etc all the way up to the first one which the click originally triggered.
I think my explanation may be more complicated than the actual flow.

Let's see if I can make a diagram...
Code: Select all
on mouseUp
add 1 to x
if x <> 4 then [mouseUp]
add 1 to x
if x <> 4 then [mouseUp]
add 1 to x
if x <> 4 then [mouseUp]
add 1 to x
breakpoint -- end 3rd call
beep
breakpoint -- end 2nd call
beep
breakpoint -- end original call
beep
end mouseUp
This one only has 3 calls but maybe it shows the idea anyway.