-
-
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
HasLength() is the default iteratorsize for all custom iterators? Even if they don't define length? (Breaks Collect) #15977
Comments
Is your |
@mschauer In this example, well no. My real code is doing tokenisation on long (multigigabyte) files. |
Ok, you are correct, |
Well, good to know it was on purpose. 👍 I personally prefer when breaking changes are made to core language parts But I do actually love that Julia is not at all afraid to break things to allow for the language to become better. I'ld rather undocumented breaking changes, than stasis. |
The new iterator traits definitely need mentioning in the interfaces section of the documentation. We should be more careful that new features need documentation, not just implementation. |
I wrote a short recap of the changes from what I understand: https://gist.github.com/mschauer/c8d8b7eb5b455cb12ddc9bda15695203 |
@JeffBezanson, do you agree with the recommendations in the last paragraph in the gist? |
ping @JeffBezanson iterator traits are still very poorly documented, can you please respond with some feedback on @mschauer's proposal to fix that? @mschauer probably easier to review if you open that as a PR |
I noticed this as a potential concern while implementing #17006 and found this. @mschauer, your writeup looks correct (though there are a couple of layout and wording issues, folks here can help smooth those). It's also possible that |
@timholy Wait a second,
reads like an argument for the default |
Yes, I meant it as an argument in favor of It's even more important for |
Ping again, @JeffBezanson are iterator traits really still undocumented? |
Btw., I am just waiting for the outcome of #17053 before making changes |
I think the outcome is that we won't be making any further API changes or trait additions before 0.5 if we can absolutely avoid it. We do however desperately need docs for iterator traits as they currently are, and I consider that RC-blocking. Jeff is evidently on vacation, but @mschauer would you be willing to submit a PR? |
Given that Another way to phrase it might be to say that you should define at least one of |
Yes, that's a good description; saying |
I was confused as to why my custom iterator, was failing to
collect
Consider the MWE:
Running with a for loop works fine:
Collecting Breaks:
This is true -- there is not method to find the length of a
::Foo
So why is it being ask?
Because
It thinks it has a length.
I think it is coming from:
julia/base/generator.jl
Line 35 in c603a79
The workaround is to add to my definition
But I feel like this should be being inferred, by the face that neither
size(::Foo)
orLength(::Foo)
are defined?The text was updated successfully, but these errors were encountered: