title: Define and use functions inside macros
body: <p>Following this example:</p>
  
  <pre><code>defmodule Greetify do
  
    defmacro __using__(_) do
      quote do
        Module.register_attribute __MODULE__, :greet, accumulate: true,
          persist: false
        @before_compile Greetify
      end
    end
  
    defmacro __before_compile__(env) do
      greetings = Module.get_attribute(env.module, :greet)
      for {name, age} &lt;- greetings do
        IO.puts "#{name} is #{age} years old"
      end
    end
  
  end
  </code></pre>
  
  <p>Can it be possible to define internal functions to use within the macro?</p>
  
  <p>For example:</p>
  
  <pre><code>  defmacro __before_compile__(env) do
      greetings = Module.get_attribute(env.module, :greet)
      say_greetings(greetings)
  
      defp say_greetings(grettings) do
        for {name, age} &lt;- greetings do
          IO.puts "#{name} is #{age} years old"
        end
      end
    end
  </code></pre>
  
  <p>Trying this the compiler complais with function say_grettings is not defined</p>
  
  <p>That example source <a href="http://elixir-recipes.github.io/metaprogramming/accumulating-annotations/" rel="nofollow noreferrer">http://elixir-recipes.github.io/metaprogramming/accumulating-annotations/</a></p>