-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
manual/workflow-tips: simplify the basic workflow (& explain _why_ we put code in a module) #48319
Conversation
suggestions for other wording welcome ("the |
doc/src/manual/workflow-tips.md
Outdated
The key here is to encapsulate the code in a module. | ||
If it were not so, and the code was ran directly in the `Main` module of the REPL, | ||
you would not be able to remove methods or edit `struct` definitions, without restarting Julia. | ||
|
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.
The key here is to encapsulate the code in a module. | |
If it were not so, and the code was ran directly in the `Main` module of the REPL, | |
you would not be able to remove methods or edit `struct` definitions, without restarting Julia. | |
The key here is to encapsulate the code in a module. | |
This makes the global state more isolated, so that it is not affected by prior content in the `Main` module of the REPL, | |
or methods and `struct` definitions added before. | |
This reduces the need to restart Julia in this workflow. | |
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.
(changed to word this only in the positive, and to mention another benefit of this workflow tip)
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 for the review and suggestion :)
The isolation from previous REPL commands is indeed another benefit.
Maybe confusing for new users that "the global state" refers to the state inside the module?
Does using a module reduce the need for restarting Julia, or (virtually) eliminate it?
I'll tag the original author of this section (4b51aef), @twadleigh, to ask them what they think.
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.
Actually this edit changes what I meant: I think that in an "efficient interactive workflow", which this guide is about, the main advantage of a module is not having to restart Julia when editing structs or removing methods.
Thinking about this whole section more, I think it can be simplified further:
|
I rewrote (simplified) the entire section. Very open to new suggestions, this is a draft. Edit: (seems like I can't add reviewers). Input welcome anyway |
I came upon this piece of documentation again after seeing this popular post by @bkamins: https://discourse.julialang.org/t/how-to-clear-variables-and-or-whole-work-space/10149/21?u=tfiers
("How to clear variables and/or whole work space?" → "Work in a module")
This small addendum to the Worfklow Tips section of the manual answers "but why should I bother making that module";
basically putting the gist of that discourse thread in the documentation, where more people might see it