defmacro defkv(kv) do
quote do
Enum.each unquote(kv), fn {k, v} ->
def unquote(k)(), do: unquote(v)
end
end
end
If you try to run our new macro, you will notice it won’t even compile, complaining that the variables k and v does not exist. This is because of the ambiguity: unquote(k) can either be an unquote fragment, as previously, or a regular unquote as in unquote(kv).
文档里有一处修改是这样的,这里的 ambiguity 怎么理解? 这两种情况是什么?