Re: Weird numeric for loop counter variable behavior

  • From: bobk@xxxxxxxxxxxxx
  • To: luajit@xxxxxxxxxxxxx
  • Date: Thu, 06 Mar 2014 07:15:37 -0500

Cheyi:
  This is normal behavior in almost all programming languages with For 
constructs. The counter variable "i" is incremented until the test for it being 
greater than the terminating value "N" is true and the loop is then exited. 

Bob Krummenacker

On March 6, 2014 1:54:38 AM EST, Cheyi Lin <cheyi.lin@xxxxxxxxx> wrote:
>Hi, I have a rare numeric for loop variable behavior in LuaJIT 2.0.2:
>
>local N = 4
>for i = 1, N do
>  if i < 0 or i > 4 then
>    print(i, N)  -- Is this possible ??
>  end
>end
>
>Yes, It really happened a couple of times a week in my project, I got
>i = 5 and N = 4 !
>
>How did it happen? Could someone give me some clues/hints?
>Thanks.
>
>Cheyi

Other related posts: