Skip to main content
Discovery icon for Retro Dev Discord server

Retro Dev

7,601 Online
44,248 Members
# retro-chat5 people

Lua variable arguments

There's a desire for a feature allowing functions to take a variable number of arguments (like `func(args...)`) directly, especially when wrapping other functions.

  • The core problem is wanting to pass a variable number of arguments to a function without knowing how many there will be in advance, especially when wrapping other functions.
  • A desired functionality is akin to `func(table.unpack(args))` where `args` is a table of values whose length is not constant.
  • This would be useful for generic functions that take other functions as arguments, such as a `delay(time, func, ...)` or a custom `exec` function that wraps another function and its arguments.
  • The difficulty in RetroStudio is that the 'run function' block expects a fixed number of arguments, making it hard to dynamically pass arguments from a table.
  • One member suggested packing arguments into a table and then using `table.unpack` to pass them, but noted this doesn't directly solve the issue of a function expecting an unknown, variable number of arguments without presupposing them.
Summarized from recent messages, might be inaccurate

More conversations

Talk, Play, &
Hang Out

Find your space to hang out, discuss the latest updates with the party chat, and see who's down to join your next match.
Get App