Sharing with the community: text transcoding libraries

This is IMO one of the negative consequences of the library taking user options during compilation via config.exs. In most cases, I’d prefer if these options were taken at runtime, preferably as plain function arguments. If this is not a viable option (e.g. performance implications, or too complicated interface), and the lib team opts for compile-time generation, it would be better if the options were taken through a macro. So for example, in this particular case something like the following would work better:

defmodule MyCodepagex do
  use Codepagex, encodings: [...]

  # ...
end

With such interface, even if you take encodings from config.exs (don’t really see the need for that, but ymmv), changing the config script would lead to this module being recompiled, and everything would work as expected.

Not saying it’s the best approach though. If taking options at runtime works fine, this would be my preferred option.

3 Likes