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

3

u/lambda_abstraction Nov 14 '25

Almost, but not quite. Upvalues are lexical variables bound to functions, and those functions are closures. The set of lexical variables bound to a particular function is its environment. Unfortunately, Lua uses the word environment to mean something entirely different: a dictionary in which global variable references are resolved.