local fn_info = debug.getinfo(fn, 's')
fn_info.source --=> @.repl.lua
fn_info.linedefined --=> 6
fn_info.lastlinedefined --=> 8
fn_info.nparams --=> 2
fn_info.isvararg --=> false
fn_info.nups --=> 1
This allows us to add support for functions defined outside of stdin. For a
REPL usecase, this means sending loadfile(<file>)() to the REPL instead of
the lines themselves.
nups ("number of upvalues") can be used to see if the function requires a closure.
With this information we can support functions that:
- Do not require closures (i.e.
nups == 0)
- Are defined somewhere other than stdin
This allows us to add support for functions defined outside of stdin. For a
REPL usecase, this means sending
loadfile(<file>)()to the REPL instead ofthe lines themselves.
nups("number of upvalues") can be used to see if the function requires a closure.With this information we can support functions that:
nups == 0)