Nvim
May 8, 2019, 9:32am
1
mix phx.new hello
creates
defmodule HelloWeb.HelloController do
use HelloWeb, :controller
def world(conn, _params) do
render(conn, "world.html")
end
end
How is HelloWeb
visible in this module? There are statement that includes it. Is it the HelloWeb
module in hello_web.ex
? Please explain.
What do you mean by visible? A module name (HelloWeb
) is just an atom, so it’s visible everywhere it is written like any other literal value (ints, strings).
1 Like
Probably in lib/hello_web.ex
.
Nvim
May 8, 2019, 1:10pm
5
What’s this,
defmacro __using__(which) when is_atom(which) do
apply(__MODULE__, which, [])
end
NobbZ
May 8, 2019, 1:15pm
6
A macro definition, it effectively delegates to the function that is described through the passed in atom when called.