lua-users home
lua-l archive

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




On Wed, May 13, 2020, 12:42 Andrea <andrea.l.vitali@gmail.com> wrote:
I am sorry I do not understand but this is due to my ignorance 

Where do lexical block start? They end at “end”, they can start with “do”.

Also I assumed lexical blocks start with the function definition and end at their end.

Does “then” introduce a new lexical block which can end with “else” or “end”? Is this the way it works in Lua?

   Andrea 

Yes, each time you enter a conditional block, do-block, or loop, you can declare variables that will go out of scope at the end of that block. Bonus fact: the iteration variables in for loops in lua go out of scope between iterations of the loop.

If you are familiar with _javascript_, I believe this is the same as _javascript_'s let and const, and Python's behavior is the same as _javascript_'s var.

_______________________________________________
lua-l mailing list -- lua-l@lists.lua.org
To unsubscribe send an email to lua-l-leave@lists.lua.org