I’m trying to make a call to a function, but before the call is made I need to change the arguments (e.g. add an argument). I have tried using macros, but there is a problem because it doesn’t return the quoted expression of a correct function call - the last element should be a list of arguments, but my list of arguments is currently in a variable.
defmacro macro({{:., meta1, [{fn_name, meta2, module}]}, meta3, _}, args) do
{{:., meta1, [{fn_name, meta2, module}]}, meta3, args}
end
def launch(server_fn, args) when is_function(server_fn) and is_list(args) do
pid = self()
args = [pid | args]
macro(server_fn.(), args)
end
The macro/2 macro outputs this quoted expression, which has a problem - the last element should be a list not a variable:
{{:., [line: 492], [{:server_fn, [line: 492], nil}]}, [line: 492], {:args, [line: 492], nil}}
Is there a way to get the unquoted values of the variable args?
Any help/suggestions would be appreciated.