-
-
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
RFC: add Base.Iterators
module
#18839
Conversation
Perhaps the lazy For what it's worth (which I doubt is much), I'm personally not a huge fan of the name |
|
|
Yes, I separated the functions so that that's no longer the case. I guess I was a bit unclear; the parenthetical applies to the new functions. |
510de68
to
211d14d
Compare
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.
lgtm if green
211d14d
to
b927d43
Compare
This is probably worth mentioning in NEWS.md |
Needs a rebase and possibly that |
Yep, and it occurs to me I should probably add a doc/stdlib file+section for the module. |
cc7bfdb
to
36f1f82
Compare
36f1f82
to
7ade52d
Compare
Iterators
moduleBase.Iterators
module
We discussed this on the triage call. Consensus was that IterTools is an ugly name, and we don't want to get stuck with it. So now we have I tried this out, and the name conflict doesn't seem to be inconvenient. You can even do both This will be more future-proof; we can potentially break up the Iterators package by (1) moving some things to Base.Iterators, (2) move more exotic iterators to their own packages. Then we'd be left with just |
wouldn't it be better to move everything from Base.Iterators to Iterators.jl and make it a default package? |
I feel like the best solution is to either move everything from Iterators.jl into Base (a la Rust) or reexport Base.Iterators from Iterators.jl so that users don't ever have to run into name conflicts. |
That's a good idea. One tricky thing about Base.Iterators is that it has some functions that are very widely used in Base, plus some things that are needed for lowering generators and comprehensions, so it can't be fully separated in any meaningful way (unless we split it into ImportantIterators and OtherIterators). |
Seems that anything that isn't absolutely a dependency of all other code written in the language should eventually be a package, so important vs other is a fair dividing line between what should be here and what shouldn't. |
You can pull that thread until there's no sweater left. |
are we serious about #5155 or not? |
Yes, but my point is that there's no hard line between what's necessary for Base and what isn't – and it can change over time. We should try to make the distinction a little less transient. |
Yeah I'm serious about it --- in that issue I list 26 modules to move out, without even mentioning this one. |
Yes and that's a good list, but I don't see why the parts of Iterators that aren't needed for bootstrapping or lowering shouldn't be on it too. |
Maybe so; it's just a pretty small amount of code that's broadly applicable. Several of the iterators are <30 lines of code each, so moving them is a low priority. Some belong by symmetry; for example I wouldn't want |
@@ -23,6 +23,7 @@ export | |||
Docs, | |||
Markdown, | |||
Threads, | |||
Iterators, |
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.
this probably shouldn't be exported, won't it conflict with the package name?
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.
Good point. I tried both ways, and exporting it didn't change the situation much. The way using
works, if you do using Iterators
first it loads the package with no warnings. All the other public submodules of Base are exported, so I decided to be consistent. However I'm willing to remove all or most of these exports as part of #5155; some will become top-level modules instead of submodules, and for the remainder we can change the policy on exporting 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.
if you do using Iterators
without the package installed will it behave differently than with?
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.
No. using
can't see Base.Iterators
unless you do e.g. import Base.Iterators
.
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.
Ah. But if exported from Base, does Iterators
refer to something different before you do using Iterators
vs after?
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 that case yes, and you get the usual WARNING: imported binding for Iterators overwritten in module Main
.
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 looks like this is now confusing precompile because it finds the Main.Iterators
binding (probably using the wrong logic) and ends up having that shadow the real Iterators package. This shows up as breakage of the Compose package:
julia> using Compose
WARNING: The call to compilecache failed to create a usable precompiled cache file for module Compose. Got:
WARNING: Module Iterators uuid did not match cache file.
julia> using Iterators
WARNING: imported binding for Iterators overwritten in module Main
julia> using Compose
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.
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.
Yes, precompile should use the equivalent of eval_import_path.
Perhaps #17935 could also be included with this |
This removes a spurious warning if Base.X is deprecated to Mod.X, and one does `using Mod`. `X` is available from both `Base` and `Mod`, but we asked for the non-deprecated one so there should be no warning.
7ade52d
to
7cc22c5
Compare
fixes deprecation warnings on v0.6. see JuliaLang/julia#18839 for more details.
fixes deprecation warnings on v0.6. see JuliaLang/julia#18839 for more details.
On 0.6 julia> filter(x->true, (1,2))
WARNING: filter(flt, itr) is deprecated, use Iterators.filter(flt, itr) instead.
Base.Iterators.Filter{##3#4,Tuple{Int64,Int64}}(#3, (1, 2)) Shouldn't that be handled by |
What should be handled by the deprecated |
Sorry, I misunderstood the deprecation strategy. Never mind, it makes sense. |
Wraps the definitions that were in
base/iterator.jl
in a module, as has been discussed.zip
andenumerate
are so widely used that we should probably continue to export them from Base.Base
exports them as part of a deprecation, thenusing IterTools
will conflict. We should add a rule that deprecated bindings can be shadowed instead of giving the "both X and Y export Z; uses of it must be qualified" error.Base.filter
andIterTools.filter
into two functions (since the latter is lazy and the former is eager). This is up for debate.