Lua.VM.Display.Closure (Lua v1.0.0-rc.1)

View Source

Display wrapper for a Lua closure ({:lua_closure, proto, upvalues}) returned across the Lua.eval!/2 boundary.

Carries the closure's source, line, and arity for human display. The wrap fires in both decode: true and decode: false modes because raw closure tuples have always leaked to the user.

Fields

  • :source — source name attached to the closure's prototype (for example "<eval>" or "my_script.lua").
  • :line — first line of the closure's body, derived from the prototype's :lines field.
  • :arity — the number of declared parameters. Variadic closures have :arity equal to the fixed-parameter count; the variadic flag is reflected by appending +... in the inspect output.
  • :vararg? — true when the closure accepts varargs (...).
  • :upvalue_names — the closure's upvalue names in declaration order (for example ["_ENV"] for a loaded chunk).
  • :ref — the original {:lua_closure, proto, upvalues} tuple so callers can still reach the live closure (for example via Lua.call_function/3).

Internal pattern matches against {:lua_closure, _, _} are unaffected; the wrap is a display affordance applied at the eval boundary only.

Summary

Types

t()

@type t() :: %Lua.VM.Display.Closure{
  arity: non_neg_integer(),
  line: non_neg_integer(),
  ref: tuple(),
  source: binary(),
  upvalue_names: [String.t()],
  vararg?: boolean()
}