-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add transitive dependencies section to Meta-programming anti-pattern #13766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add transitive dependencies section to Meta-programming anti-pattern #13766
Conversation
for example, will also create a compile dependency. Some external libraries may also | ||
create compile dependencies by using macros. | ||
[`mix xref`](https://hexdocs.pm/mix/main/Mix.Tasks.Xref.html#module-a-brief-introduction-to-xref) | ||
can be useful to identify these dependencies and refactor the code to remove them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @Gladear! I am wondering if this is the best place to have this guide. The issue here are not strictly related to meta-programming. After all, simply using Foo.bar()
in the body of a module will be enough to trigger this issue. I wonder if it fits either in Code or Design ones. It feels a bit higher level to be in Design, but it is not strictly about Design either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just pushed an anti-pattern on compile-time dependencies, which I think is the most appropriate for this guide, inspired by the conversation started here: https://github.com/elixir-lang/elixir/blob/main/lib/elixir/pages/anti-patterns/macro-anti-patterns.md#compile-time-dependencies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wondered that too when writing the guide. It actually does feel like an antipattern, more like a warning when using macros. I wondered if this could be added to the meta-programming guide, maybe after Write macros responsibly ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my mind, the core of the issue is that this warning is for application developers first, not library developers. It is hard to think of the best place to put it at right now, besides mix xref. :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, OK, I get what you're saying.
I'm looking at the Mix & OTP
section of the documentation. What about linking it indirectly?
- adding a reference to
mix compile.elixir
in "Introduction to Mix" > "Project compilation" - on a "to go further" kind of link, - adding a link to
mix xref
there - there's already a small paragraph about dependencies between files, - adding an antipattern section to
mix ref
?
I think it has the advantage of being simple to find. People will search for "compilation" in the Elixir documentation if they're interested in the topic, and they'll find "Project compilation" under "Introduction to Mix". Then they can expand on the topic easily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So to be clear, you want to add more links to the existing mix xref
docs, right? Would you like to send a PR for those? Also, do you think some of what you wrote could be added to mix xref
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, that's the idea : add links to mix xref
and document this issue in there.
I'll create a new PR for the links and update this one to move this section I wrote in mix xref
when I get access to my computer again, starting Monday 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! I'm sorry, I completely forgot about this PR 😅 I updated it to add the links I talked about earlier.
7a1ebc5
to
38606ba
Compare
💚 💙 💜 💛 ❤️ |
As discussed in #13762 (comment), I added a "transitive dependencies" section to "Meta-programming anti-patterns".
I obviously open to feedback, whether typos or more general remarks about the content of the section. I've tried to keep it simple whilst exposing the problem, linking to
mix xref
when complexity arises.This also fixes the documentation of
mix xref
a bit, since it only stated "runtime dependencies" can cause compile-connected ones, whilst all dependencies are affected.