-
Notifications
You must be signed in to change notification settings - Fork 59
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
[PROPOSAL] Iterator Improvements (Step, Reverse, Float) #104
Comments
This can "easily" be implemented on user side, like it was done there: |
To continue the conversation from the issue, sure it "can" be implemented by the user. But something like a simple reverse iterator seems like an unnecessary thing to "require" a custom library for. Where the lacking of one suggests a user do |
There's a long-standing tradition that whenever reverse iteration comes up, someone points out the
|
I suppose an issue with the reverse iterator is that it could be used with values that are unknown at compile time, e.g. final x = getSomeInt();
// Forward or Reverse Iterator ?
for (i in (10...x))
trace(i); // 10, ??, ??, ... In this case, the code would have to decide at runtime which direction the iterator has to go in. This would make compile time optimisation much more complicated (i.e. inlined iterators, loop unrolling, etc.). It might result in having to generate 2 code paths for each for loop, one for the forward case and one for the backward case, which is obviously not ideal. This makes repurposing the existing |
my iteration lib may also be useful for some, thinking of putting on haxelib soon so improvements welcome, especially from Rudy I have not looked into his lib yet, but I am sure it will be good. |
I'd like to see more functionality for iterators, inspired by
Ruby
.I was actually able to implement
step(value:Int):IntIterator
locally without modifying compilation, but reverse and FloatIterator would require compiler changes (I got a "Cannot iterate backwards" error)This is pre-draft, but if nobody has any obvious problems with it I will write up a more formal proposal
The text was updated successfully, but these errors were encountered: