Wait 0 doesn't

Dar Scott dsc at swcp.com
Mon Apr 28 20:12:00 EDT 2003

On Monday, April 28, 2003, at 07:05 AM, Jim Hurley wrote:

> This will be of little concern to most, but for me it made a big 
> difference.

I tried this on OS X 10.2.5 Revolution 2.0 B2.5:

on mouseup
   put the long seconds into a
   put the long seconds into b
   wait 0 seconds
   put the long seconds into c
   wait 0 milliseconds
   put the long seconds into d
   wait 0 ticks
   put the long seconds into e
   put (c-b) & "  " & (d-c) & "  " & (e-d) into field "report"
end mouseup

I got results like this:
0.000708  0.000084  0.000075

There are high outliers, of course, so you need to click the button 
several times to make sure the values make sense and look consistent.

With a delay of .7 ms or greater the results are about the same.  The 
seconds delay seems to have a minimum.  Perhaps this is related to 

(I had this vague notion that everything was converted to seconds 
underneath, but this seems to suggest otherwise.)

I also modified this to allow testing on XP, but I was not able to see 
a similar difference in "wait 0 seconds" on XP.

> Of course it is easy to see why the compiler is not prepared for the 
> fool who would program a wait of 0 milliseconds.

Zero is a special case that might come up in a general situation.  It 
should be handled well.  Since the TD for "wait" does not specify the 
resolution or the minimum delay, it is hard to way what well means 
here.  My concern in surprises like this is that they may be indicative 
of other problems.

There might also be a reason for one to explicitly use zero.  One might 
want to "wait 0 with messages" to allow messages to be processed.  This 
does not work with events (such as a click), though; a nonzero wait is 
required for those.

Dar Scott

More information about the Use-livecode mailing list