I think the name “instance function” is a loan from Ruby, though to me it doesn’t really make sense here as there’s no such thing as an instance in Elixir.
Here Ju is using a module attribute as a mutable variable that can be referenced before it is defined in order to create a recursive anonymous function. This is needed because in Elixir anonymous functions cannot refer to themselves, unlike in Erlang.
You can’t assign module attributes inside functions, so it would be used more like this:
defmodule Thingy do
@func fn ->
# Can call itself using @func.()
end
@func.()
end