The Elixir macro found in magic.ex allows you to call functions without specifying the arguments (as long as the name matches a local variable).
A module that will turn functions annotated with
@replace :trueinto functions with an additonal argument and then add arguments to zero arity function calls for functions that require arguments.
defmodule Thing do
use Magic
@replace true
def my_func() do
user_id = :foo
password = %{plaintext: "lol ok"}
object = new_arg
object = put_user_id()
arg = :bar
object = put_another()
end
defp put_user_id(object, user_id) do
Map.put(object, :user_id, user_id)
end
defp put_another(object, arg) do
Map.put(object, :arg, arg)
end
endThe code above turns my_func/0 into
def my_func() do
user_id = :foo
password = %{plaintext: "lol ok"}
object = new_arg
object = put_user_id(object, user_id)
arg = :bar
object = put_another(object, arg)
end
I am not responsible if you actually use this. Please don't use this, it was a fun exercise in writing macros.