lua-users home
lua-l archive

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


Is this an official behaviour also in future Lua versions?

for Loop=0,1,-1 do
   print('Never') --> not executed
end
print('Ready') --> 'Ready'

I like it because it make things much more easier as the other way:
checking loop state with the end statement.


And is the old rule also correct with Lua: that code in the for loop
reduces the speed of the loop massively?

Example 1:

   Pointer=nil

   for Loop=Stack[n],1,-1 do
      if Stack[Loop]==true then
--       do something         
      end
   end


Example 2:

   Pointer=nil

   for Loop=Stack[n],1,-1 do
      if Stack[Loop]==true then
         Pointer=Loop
         break
      end
   end

   if Pointer~=nil then
--    do something
   end


In which case, depending on size of "do something", should be used
example 1 or example 2.




Markus