manhvu
In a large repo, working with module need to add alias too much is quite annoyed and not good for organizing code.
I think better add support for namespace can bring more convenient for dev.
This is a basic example for namespace cross multi modules.
Example:
defmodule MyApp.A do
namespace MyApp.DataProcessing
def a do
# do somethings
end
defmacro macroA(name, opts) do
#...
end
end
defmodule MyApp.B do
namespace MyApp.DataProcessing
def b do
# somethings
end
end
defmodule MyApp.C do
namespace MyApp.DataProcessing
def do_something(data) do
data
|> A.a()
|> B.b()
end
A.macroA :wrapper, type: :json
end
LS can easily to suggest dev in a namespace.
Pros:
- Less typo like add alias for module.
- Make code clean than before.
- Better for LS suggest in case work in namespace.
Cons:
- Make complicated if bring support for
import,requireoruse. - Can make dev confused.
Trending in Proposals: Ideas
I’m a bit in a fuzz about this topic. I’ve worked out some sort of Dropbox feature for a specific client. This feature allows him to uplo...
New
I recently learned about this API and was surprised there’s no explicit support for it in the the Phoenix.
Example use cases:
A webs...
New
Other Trending Topics
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with.
But I don’t use it anymore.
Serverless was the promis...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #ai
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #metaprogramming










Showing Posts 1 to 9- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
benwilson512
This idea is essentially implemented in the library Boundary GitHub - sasa1977/boundary: Manage and restrain cross-module dependencies in Elixir projects · GitHub
Do you have any thoughts on how this proposal differs, beyond basically the implicit aliasing?
FlyingNoodle
Please don’t. I know this isn’t a democracy but I vote against it.
BartOtten
At mobile so in short:
Now you can
use DataProcessingAliasesin the modules. Mixed ground between explicit and implicit…?manhvu
Thank you for your suggestion, I have an idea wrap a macro for this but need a manual job like put all module name to one place like config for expand macro later.
BartOtten
What would you gain with that? Imho at maximum a few lines less at the cost of macro in macro and a separate config.
Notice you can add multiple namespaces in a single file. So the example I gave can be copied over and over in a ‘config’ file.
As a benefit of the ‘manual macro’ solution you could also add common aliases not in the same ‘namespace’ such as Ecto.Repo. Enforce no aliases in the modules themselves and you get a boundary overview of all namespaces in a single file: every ‘out of pattern’ alias sticks out like a sore thumb.
mudasobwa
The democracy is all about the illusion your vote counts. To vote per se you don’t need a democracy, colorful beans and a couple of amphorae suffice.
manhvu
Oh, I like this way than mine. Thank you so much!
A little of bit more about my case. I usually work with quite large repos, sometimes my project is an umbrella project (after that maybe I split it to multi nodes). Too many modules with long name make me feel tired for remember and repeat again and again in each module. That way I’m finding a new way when work with Elixir.
manhvu
MyApp.DataStoreis alias and need to unquote for using. For simplicity, I created a module like:BartOtten
Ah, forgot about that. Need to expand it before passing it as function argument. Small change but then you can just use module names.