fceruti
Elixir formatter & macros - every time I create a macro I need to add it to the local_without_parens list
I’ve noticed something in my own code, that every time I create a macro, I need to add it to the local_without_parens list in .formatter.exs.
I’m not alone in this, Phoenix, Ecto, Ash, and probably many others, have this long lists of all the macros they’ve defined.
Wouldn’t it make sense to make this either the default behaviour, or at least have a flag like, macros_parens: false? Is there a technical limitation for doing this?
Most Liked
LostKobrakai
I’d also argue that setting all macros as without parens would be a bad default. Yes many of them look a lot better without parens, but not all macros are used in different ways to functions. E.g. the macros in explorer are macros because they need to be, but they’re generally not used differently than their function counterparts.
josevalim
The formatter does not know if something is a macro or not. To know that, it would need to expand and execute macros, which would make formatting slower.
fceruti
Thanks for the responses! I get it now
Popular in Discussions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









