title: elixir define dynamic functions inside macro
body: <p>I am trying to define dynamically functions inside <code>defmacro</code> but can’t understand why function value is unavailable inside function itself</p>
  
  <pre><code>defmacro __using__(_) do
    Enum.each ~w(public private), fn value -&gt;
      def unquote(:"make_#{value}")(user = %User{}) do
         %{user | privacy: value}
      end
    end
  end
  </code></pre>
  
  <p>Elixir expands by default <code>value</code> to <code>value()</code> and then says that there is no such function</p>