lua-users home
lua-l archive

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


Op Ma. 25 Mrt. 2019 om 00:17 het Dibyendu Majumdar
<mobile@majumdar.org.uk> geskryf:
> > I was wondering whether upvalues have function scope, i.e. each function
> > has a list of unique upvalues where each upvalue is identified by name
> > only.
> >
> > Hope the question makes sense.

The documentation of `debug.getupvalue (f, up)` says:

~~~~
This function returns the name and the value of the upvalue with index
up of the function f. The function returns nil if there is no upvalue
with the given index.

Variable names starting with '(' (open parenthesis) represent
variables with no known names (variables from chunks saved without
debug information).
~~~~

Thus indeed there is such a list, but it might no longer be available
at runtime.

You can see it with `luac -l -l myscript.lua`.