Would it be possible for
config to be a macro which creates accessor functions for the environment variables? E.g.:
# config/config.exs config :my_app, :key, "value"
…currently enables this kind of access:
"value" = Application.fetch_env!(:my_app, :key)
But instead, I imagine the
config macro generates functions at compile time enabling this usage:
"value" = Application.MyApp.key()
The big win is the compile-time checking & LS completion support for
key. It’s also shorter and more expressive. It doesn’t rely on the programmer remembering to use
I’m new to macros as well as the
Mix.Config system. Would this be possible?
Update: A couple of existing solutions are,