-
-
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
loading code simplifications #29807
loading code simplifications #29807
Conversation
5d81ad7
to
ad849fa
Compare
I'm not entirely sure I would call a 40 line increase of code a simplification. I'll review in more detail, but in terms of simplicity this seems like pretty much a wash to me. |
Since the meat of this change is switching from |
One simplification that I had been wanting to do was to use the nil UUID uniformly to represent the absence of a UUID instead of the |
I don't think that SLOC has much association to code-complexity. I find it's nice when they happen to correspond, but that generally longer code can be simpler and therefore clearer. For example, the old code had a function named (approximately)
Yes. As I mentioned above "the biggest change here is removing all of the 3VL (UUID, true, or false) in favor of nullable (PkgId or nothing)." (Actually, my motivation for changing it was as a code-exercise to test my understanding of it and look for any bugs or unexpected interactions that I should be aware of. As such, I tried to change or re-write anything that seemed overly-complex—and see if that helped clarify it.) |
Ok, but why is that better? Can you give some motivation? |
OK, I get that that's not directly a reason, but merely seemed to be evidence of there being an issue. But explaining why it felt bad is harder. It just felt wrong to me, because it didn't quite match the documentation. Each of these functions was implemented to return |
Ok, that makes sense. Thanks for explaining the motivation. I'll take a look in light of that. |
b381fd7
to
66de995
Compare
66de995
to
130a2c6
Compare
Given the impending code freeze, I'd like to merge this in a couple days. |
I suppose that's fair given that I haven't reviewed it yet, but I'd still like to review it, so I guess that puts a deadline on my review. |
@@ -117,8 +117,7 @@ end | |||
|
|||
const ns_dummy_uuid = UUID("fe0723d6-3a44-4c41-8065-ee0f42c8ceab") | |||
|
|||
dummy_uuid(project_file::String) = isfile_casesensitive(project_file) ? | |||
uuid5(ns_dummy_uuid, realpath(project_file)) : nothing | |||
dummy_uuid(project_file::String) = uuid5(ns_dummy_uuid, realpath(project_file)) |
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.
You don't want to call realpath on a project_file
that doesn't exist since it breaks. Perhaps you've rejiggered the code so that never happens but it seems better to either return nothing
or perhaps to return the nil UUID since that's what we say the UUID of a non-existing project file is?
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.
It couldn't happen before either (we only call it immediately after calling open(project_file)
, and that certainly would have failed if it didn't exist). I assume at some point it was possible, but then got refactored out by the time the PR was made.
It took me quite a while to review #29946, so I've barely started reviewing this. I can take a look at it again next week, please don't merge until I've gotten to review. |
Bump. It's unfortunate this has gotten lost from v1.1 |
130a2c6
to
492dbfd
Compare
492dbfd
to
0b14f44
Compare
0b14f44
to
d19c53b
Compare
Attempt a simplification of the module-search logic. Previously, it was mostly using 3VL (UUID found, UUID not-found, environment not-found). However, it turns out that it can also be handled via nullable (e.g. is the Pkg identified or not), which also maps more easily into a dict-like view of things (is the Pkg identified in this set or not).
d19c53b
to
2bd4956
Compare
I'm still not convinced that this is actually a simplification—it is a net gain of 50 lines of code, after all. But I guess it's probably not harmful as long as the very thorough test suite continues to pass. |
In my attempts to better understand the existing loading code (before making more major changes, such as making the environment maps explicit for the Distributed and precompile code), I experimented with trying to simplify the code logic here and adding or expanding upon comments. I turned up a few minor bugs (such as places where we returned
nothing::Bool
) and other slight inconsistencies (such as potentially attempting to searchX/src/X.jl/src/X.jl
). The biggest change here is removing all of the 3VL (UUID, true, or false) in favor of nullable (PkgId or nothing).Relatedly, I then turned to the code-loading docs, and attempted to simplify and clarify those, and correct a couple places where the code doesn't quite do what was documented. I'd like to do a bigger rearrangement of this also (splitting it into a couple files, and possibly adding more support to Documenter to handle nested documents better), but sometime later.
I'm not strongly opinionated about merging all of this, and rather expect that we might cherry-pick some bits or alter others further (both in the docs changes and in the code).