-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Chain all iterator in array that isn't determinate in compilation-time #6532
Labels
Comments
I just implemented a version with simple spec. here |
xqyww123
added a commit
to xqyww123/crystal
that referenced
this issue
Aug 20, 2018
RX14
pushed a commit
that referenced
this issue
Sep 10, 2018
* Iterator could chain indetermined number of iterators now Fixes #6532 * Formatted the code * Simplified the spec & Improved comments. Finally, I remain `#chain` in the same, for the purpose of performance, but added some comments to instruct this feature. Maybe I had tried my best to improve linguistics, but I'm sorry I'm not good at foreign languages. If it's still not good enough, helps is really really appreciated, thanks. * Improved comment linguistic, agian... * Iterator could chain iterators of different type * Type of ChainAll could be inferred by compiler
ezrast
pushed a commit
to ezrast/crystal
that referenced
this issue
Oct 2, 2018
…ng#6570) * Iterator could chain indetermined number of iterators now Fixes crystal-lang#6532 * Formatted the code * Simplified the spec & Improved comments. Finally, I remain `#chain` in the same, for the purpose of performance, but added some comments to instruct this feature. Maybe I had tried my best to improve linguistics, but I'm sorry I'm not good at foreign languages. If it's still not good enough, helps is really really appreciated, thanks. * Improved comment linguistic, agian... * Iterator could chain iterators of different type * Type of ChainAll could be inferred by compiler
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have an array of iterators depends on user's input, so cannot be determinate in compilation-time, and now I want to chain all of them together.
The first one
chain_all1
triggers a compilation error :And for the second one
chain_all2
, compiler traps into a long time silence and ends ingeneric type too nested
.It's yet another recursive type problem, because Iterator tries to expand all code and it's impossible.
But 'chains all' is in fact practicable, by a struct stores all the iterators and implements
next
andrewind
via a loop.The code to implement a struct could be long, so I think it's should be implemented in std-lib, and a method
chain(iterators : Enumerable(Iterator))
may be provided.The text was updated successfully, but these errors were encountered: