-
Notifications
You must be signed in to change notification settings - Fork 7
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
Ranges and for loops #343
Merged
Merged
Ranges and for loops #343
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Jan 4, 2024
Closed
Merged
I think several of the language-specific tests need updated, as they still have the old |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Big refactor of integer ranges and loops. The main motivation is to simplify the AST, reduce repetition and special casing in plugins and emitters and to simplify the control flow analysis in the future.
+
(..
is understood, but emits deprecation warning (this was kind of tricky to implement since it needs type info))ForRange
,ForDifferenceRange
nodesrange_incl
(alias..
),range_excl
(alias..<
) as frontend andrange_diff_excl
as backend opcodes to fill in the functionalitytext_to_list[Ascii]
, (aliastext_to_list
)text_to_list[byte]
,text_to_list[codepoint]
opcodes, to be used for iterating over characters.ForEachKey
&ForEachPair
. They were not used and I'm not sure target langs would agree on iteration order. If we decide to add this functionality later, we can do so via atable_keys_list
opcode over which we would iterate using aForEach
=for
.mapOps
plugin, if the target lang shares the defaults with Polygolf.Cast
node. This node is used when explicit conversion from/to a type that doesn't exist in Polygolf is needed in the target language.Polygolf's
for
now means a for each loop over list items and it should be used for iterating over a range as well, similar to Python.for $i $a $b {};
should now be writtenfor $i ($a ..< $b) {}
. Old form is understood (as implicitrange_excl
), but emits a deprecation warning.for $i 10 {};
andfor 10 {};
forms are preserved without a warning.for $i $text {};
is a syntax sugar forfor $i (text_to_list $text) {};
,for[byte] $i $text {};
is a syntax sugar forfor $i (text_to_list[byte] $text) {};
similar for[codepoint]
.