6 ms·
Agree! For that very reason in Elixir `import` is discouraged in favor of `alias`
by manusachi 2y ago
Agree!
For that very reason in Elixir `import` is discouraged in favor of `alias`
- __jonas 2y agoI enjoy Elixir but this situation is quite unfortunate, there is alias, import require and use for referencing / pulling in code external to a file in some way or another, plus the possibility of calling a function from another module directly by name without an import statement using the module name – and the most annoying part of it is that none of these give an indication of which file the other module is from, which is like 50% of the utility of an import statement for me. Instead there is this pattern of naming modules based on the file path they are located in, which is not enforced.
- smj-edison 2y agoDoesn't Elixir (and Erlang for that matter) specifically require a module to not be in a specific place in order to have hot reloading of modules? Though I suppose you could still have hot reloading and require a module to be in a specific place.
- throwawaymaths 2y agoNope. Elixir doesn't care where your module lives. (You can even "nest" modules, though it's not a great practice)
- __jonas 2y agoNot sure, could be that Elixir stuck close to Erlang's module system yeah. But for example gleam [1] is another language on the BEAM (compiles to Erlang), that has a much nicer approach: All imports must be declared explicitly, and the import path in your local project is based on the file structure so you always know where something is imported from [2]. [1] https://gleam.run/ https://gleam.run/ [2] https://tour.gleam.run/basics/modules/ https://tour.gleam.run/basics/modules/