3 ms·
Collectively at work, we've abandoned the use of import, except when importing DSLs (e.g. Ecto) in favor of explicit function calls or alias. If we do need to u
by _asummers 10y ago
Collectively at work, we've abandoned the use of import, except when importing DSLs (e.g. Ecto) in favor of explicit function calls or alias. If we do need to use import, we use explicit "import Ecto.Query, only: [from: 2]", so that it's clear where a function is coming from into the namespace. Relatedly, unless otherwise necessary, __using__ macros through our code do not import modules, because it's surprising when something is in scope for no real reason. We often inline the third party __using__ macros to eliminate this.
- pawelduda 10y agoAnd I completely agree with this, I have just posted the above example to show that Elixir's syntax can be concise too in case anyone would want that. :) What Elixir has changed for me, is that I now value the explicitness of my code more than ever. And thanks to this, I aim to write code like this in other languages I use on daily basis (Ruby, Python).
- _asummers 10y agoFor sure. I just think a lot of new people get caught up in the ability to be concise for self that they forget about the expressiveness for others. Unrelated, we also abandoned 1 pipe pipelines, and instead prefer "function(arg)". Just looks better to us, despite the minor maintenance cost of having to change it if you convert to multiple pipes.