I'm writing a game engine in Elixir. (Yes, I know it's not a language inherently suited to that – the point is to look at how the use of an atypical language affects the structure of the result.)
As such, I have several supervisors to be run on game start – but what exactly they should be supervising depends on the game. My thought had been to have the user list out the necessary children, plus arguments and options, in the config.exs
file as a list of tuples, and then the supervisor itself would simply pull those tuples from the application environment and use their contents as arguments to worker\2
(or worker\3
, as appropriate).
However, I can't find any Elixir equivalent to Python's tuple-unpacking. I could do it myself for this specific case with a simple function:
def unpack_worker({module, args}) do
worker(module, args)
end
def unpack_worker({module, args, opts}) do
worker(module, args, opts)
end
But that feels clumsy at best, and would have to be written again for every function for which I might need this kind of configurability.