VeljkoMaksimovic
Is there a way to have multiple aliases, but to use as: acronym for one of them, something like this, but that actually works ![]()
alias Guard.Rbac.{Cache, RoleBindingIdentification, as: RBI}
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
Hello folks!
So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication):
toke...
New
Is there any way to avoid the Hologram compiler running when using iex? It seems like the front-end code could potentially be disregarded...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
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
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
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
- #full-time-contract
- #ai
- #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 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Eiji
What you show in best case could work as:
That’s because
optsare on same level as other aliases.Alternatively
Elixircould support this:However this looks just ugly and I guess that’s why it would be not supported at all. If you have an interesting idea how to improve that then feel free to create a proposal, but so far I do not see either a use case nor how it could look good at all.
Also keep in mind that even if such ugly-looking feature would be supported then it would be still formatted into multiple lines, so it would look like:
I believe that keeping aliases work as it’s now is best.
VeljkoMaksimovic
This is exactly what I meant
I dont agree that this is ‘ugly looking’. Elixir already supports this notation:
and I don’t see how this is any prettier (or less ‘ugly-looking’) then the example above where abbreviations are supported.
True, situations where something like this would be needed are rare, but option 1:
IMO looks cleaner then option 2:
bmitc
I don’t understand what that’s trying to specify. In this case, one is able to guess, though.
For me personally, I enforce the
Credo.Check.Readability.AliasAsandCredo.Check.Readability.MultiAliasCredo checks foralias, among others. So thealias ___.{___}syntax andalias ___, as: ___are not allowed.Mutli aliasing is really only useful in very specific scenarios. It makes copying module names harder (impossible rather), and it starts to look ugly and busy when you have a lot of modules that aren’t just under a single “namespace”. Simply typing out the shared “namespace” is really not difficult.
I personally feel that
alias ___, as: ___should be used extremely sparingly if not removed from the language. It’s use is usually an indication that the module it isasing is poorly named. And I have certainly seen it heavily abused where the module was essentially renamed withas.For the proposed:
it requires a fair amount of tracing to understand. I would suggest renaming the longer modules.
RoleBindingIdentificationcould beRoleBindingIdor even justRBIif you documented it with@moduledocand the abbreviation is clear in the context.OrgRoleToProjRoleMappingshould probably just be renamed.NobbZ
Using rarely, yes. Removing? No!
We have a codebase with more than 600 modules at work.
There are several modules ending in
Product, withinSchema,Dataloader, and what not prefixes. We do not want to repeat the type in the module name itself, therefore we are happy to be able to use:asin analias.bmitc
Removed was a bit of a hyperbole.
I know it won’t and probably shouldn’t happen in Elixir. Although, certainly several other languages, such as F#, do not have that feature, and I personally don’t miss it there. I’m not aware of it being in Erlang. Is that correct?
For Elixir, I got a bad taste for it at my previous company, where its use was definitely a symptom of poorly named modules. So many modules had such extremely similar names that
as: ___was used to mitigate this in modules and in tests. The moral of the story is that people will often take conveniences and turn them into hazards.eksperimental
And how do you deal with external librarie modules?
ityonemo
Erlang doesn’t have module aliasing at all.
I’d say the biggest reason why
as:is bad because if you wanted to do a global search and replace during refactoring, it makes it much more difficult.Same with alias Module.{…}
I use neither in my codebases.
sodapopcan
Ya, I’m not a huge fan of
{}(though it has its uses though wouldn’t miss them if they were gone) and never use:as. I even avoid just plain oldaliasa lot of the time unless it provides significant noise-reduction.One of the big things that drew me to Elixir was the high level of locality that is encouraged through official examples. I’m even just talking things like,
Enum.mapas opposed toimport Enum, only: [:map, 2]. Jumping into a function to gain a bit of context on its caller and being able to see all its dependencies without having to jump any further is a really nice feeling. Of course, it’s a balance, but I feel that often there is a subconscious emphasis put on writeability or even “prettiness” over readability and, more importantly, “scannability”.And of course the other thing I really like about Elixir is how relatively small it is and how much thought is put into backwards incompatible changes. Just by that alone, I don’t see something like nested
:ases ever making it in (not that you were necessarily suggesting they would be). Take this really well-thought-out proposal for field punning—a featured loved by many in other languages (not me)—that was rejected, for example.hst337
Yes, there is!
Behold the dark art of context magic in Elixir
Please do not try this at home
VeljkoMaksimovic
If I understand correctly, in your example
RBI.Cachewould ‘expand’ toGuard.Rbac.Cache, and same go forRBI.RoleBindingIdentificationwhich would expand toGuard.Rbac.RoleBindingIdentification, right?