If it’s stupid, but it works then it’s no stupid! ![]()
I have used atom as it’s best for what I called feature_name as those in apply_feature/1 are known at compile-time. You can use strings, integers and every other data that you can write pattern-matching for.
Also take a look at example below:
some_macro(["a", "b", "c"])
# param value in macro
# ["a", "b", "c"]
some_macro(~w[a b c])
# param value in macro
# {:sigil_w, [delimiter: "[", context: Elixir, imports: [{2, Kernel}]],
# [{:<<>>, [], ["a b c"]}, []]}
some_macro(~w[a b c])
# value of `Macro.expand(param, __CALLER__)`
# ["a b c"]
If you want to call String.to_atom/1 inside macro then:
- You can call
Enum.map(list, &String.to_atom/1)as long as you require list of atoms passed as raw list or sigil (see above example) - In function definition
String.to_atom/1call needs to be passed insideunquote/1call. - Inside
moduleandfunctionblock you can useString.to_atom/1call as well insideunquote/1call as outsideunquote/1call.
Hope that helps.






















