I have no ideas how macros work, but this is very useful and I made a string version also:
defmacro sigil_d({:<<>>, _line, [string]}, []) do
spec =
string
|> String.split()
|> Stream.map(&String.to_atom/1) # how could we do without this?
|> Enum.map(&{to_string(&1), {&1, [], nil}})
{:%{}, [], spec}
end
Works great! (so far)
iex(31)> ~d(a) = %{"a" => 5}
%{"a" => 5}
iex(32)> a
5


















