-
Notifications
You must be signed in to change notification settings - Fork 23
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
Add "for each" loop and c-style for loop #76
base: main
Are you sure you want to change the base?
Conversation
Initially, my decision was to not add anything that generates hacked blocks, but it seems like the for block is popular demand due to its performance benefits. We will definitely use the |
I also have plans to add the C/JS/Java for(i = 0; i <10; i++) loop |
added "in" to for loop syntax. It might also be renamed "foreach" or "for each" to distinguish it from C-style loops should that be a future feature |
does this compile? |
yes (at least on my machine) |
This comment was marked as outdated.
This comment was marked as outdated.
could you implement #77? |
Added c-style loops, however there are a few issues with it
Syntax:
Output:
|
|
issue 2 fixed, now behavior of for loop should be more consistent with other programming languages by incrementing after the loop runs |
should be fully working as expected now |
The "for each" loop is a hidden block that basically acts as a repeat loop with a counter. It would set a variable to 1 and increment that variable each time the loop ran. This PR adds support for that kind of loop.
Additionally adds support for c-style for loop.
Syntax:
For Each
C-style For