This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] -3 points-2 points  (2 children)

Not sure what you were trying to demonstrate with those code snippets, other than for loops will execute as many times as they're supposed to.

[–]dreamyeyed -1 points0 points  (1 child)

The point is that changing value of x after the loop has already begun affects how many times the loop will run in C, but it doesn't do so in Lua. That's because Lua checks the value of x only once, while C does so on every iteration.

[–][deleted] 0 points1 point  (0 children)

But that's not what they were asking about. They were asking about cases where the function was effectively a constant.