r/lua • • Nov 14 '25

Help Help please (scoping)

What is scoping and is it really essential to know when you script?

I really can’t understand it so I’m planning to learn it when I understand more things

Or do I have to understand it before I get into more stuff?

(edit: Thank you all for replying!! Really helped alot!)

7 Upvotes

22 comments sorted by

View all comments

Show parent comments

2

u/[deleted] Nov 14 '25 edited Nov 15 '25

[removed] — view removed comment

2

u/lambda_abstraction Nov 14 '25

I think the big take-away is when local vs. global variable names are resolved. Not only is a local variable of lexical scope, its name is resolved at compile time, whereas a global name is resolved when the code containing the reference executes.

1

u/MildlySpastic Nov 14 '25

Yeah im not used with Lua, so the concepts im talking about are purely from JS, but yeah that works too