Summary
How can I distinguish whether given AST is a variable or a call of 0-arity function in AST?
Example
I want to have macro is_variable
which will print true
when given AST is a variable, otherwise false
defmodule X do
def private_function(), do: 1
def f(variable) do
is_variable(variable) # prints true
is_variable(private_function) # prints false
end
end
PS
I took a look into lib/elixir/src/elixir_expand.erl
(in elixir’s source code) but I haven’t found the way to distinguish variable from call without raising a warning