Module.eval_quoted
You're seeing just the function
eval_quoted, go back to Module module for more information.
Specs
eval_quoted( module() | Macro.Env.t(), Macro.t(), list(), keyword() | Macro.Env.t() ) :: term()
Evaluates the quoted contents in the given module's context.
A list of environment options can also be given as argument.
See Code.eval_string/3 for more information.
Raises an error if the module was already compiled.
Examples
defmodule Foo do
contents =
quote do
def sum(a, b), do: a + b
end
Module.eval_quoted(__MODULE__, contents)
end
Foo.sum(1, 2)
#=> 3For convenience, you can pass any Macro.Env struct, such
as __ENV__/0, as the first argument or as options. Both
the module and all options will be automatically extracted
from the environment:
defmodule Foo do
contents =
quote do
def sum(a, b), do: a + b
end
Module.eval_quoted(__ENV__, contents)
end
Foo.sum(1, 2)
#=> 3Note that if you pass a Macro.Env struct as first argument
while also passing opts, they will be merged with opts
having precedence.