-
-
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
generators should lower to Iterators.map
, not Base.Generator
#34368
Comments
Thanks for opening this. I think the same holds for |
Why? |
It would be nice to be able to define |
Why do you need it to return something other than a |
@bramtayl That's my thought too. More specifically, for example, Another usecase is to overload (But maybe the first point should be resolved using traits, as discussed in the ArrayLike PR #34196) |
As I understand it right now, that'll easen the implementation of all types of operators which intend to propagate something. For example a caching iterator which automatically caches the outermost iteration call. Even if it's used as the innermost starter. This would work by dispatching on
where Now, Also, it'd allow custom return types which in turn could implement arbitrary traits. Currently, as I understand it, you can only implement that by either not using the generator syntax or by specializing the trait for Edit: We'd even be able to explicitly fuse multiple Generator layers (instead of nesting them): Iterators.map(f, c::Generator) = ((f∘c.f)(x) for x in c.iter) (Sure that already could be done aswell but it'd fit into the same generic style very well!) |
I support multiple dispatch for construction of generic generators based on lowering to A container has a larger API surface than iteration, and if |
Here is another argument: If you want to define a special method for |
Why is that: julia> Iterators.map(x->x^2, 1:10) isa Base.Generator
false
julia> Iterators.map==map
true I mean, shouldn't |
What are the chances that this will make it into LTS (=1.6 feature freeze)? I think it would be very important to have a generic style and meaning of the Iterators submodule and to be able to hook into its functions in a way that uses context information to eliminate unnecessary work. I.e. the For example, having |
This came up in the triage channel on slack, and I guess we might as well do it. Anybody want to make a PR? |
This will allow dispatching to types that aren't always
Base.Generator
The text was updated successfully, but these errors were encountered: