Metaprograming question

Im trying to generate a function in a module using quote and unquote, but it does not seem to be working, i have this

defmodule Mod do
    quote do
      def unquote(:omg)(), do: IO.puts "omg"
    end
end

, but in iex I do not have a Mod.omg() function… what am i missing ?
my endgoal is to generate functions based on a file, but i cant even get this to work…

Try this

defmodule Mod do
  def unquote(:omg)(), do: IO.puts "omg"
end

and in iex:

ex(3)> Mod.__info__(:functions)
[omg: 0]
2 Likes

Thank you so much, this was driving me crazy!