polygolf-lang / polygolf

Polyglot autogolfer for https://code.golf
https://polygolf-lang.github.io
MIT License
19 stars 7 forks source link

Ranges and for loops #343

Closed MichalMarsalek closed 8 months ago

MichalMarsalek commented 10 months ago

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.

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 written for $i ($a ..< $b) {}. Old form is understood (as implicit range_excl), but emits a deprecation warning. for $i 10 {}; and for 10 {}; forms are preserved without a warning. for $i $text {}; is a syntax sugar for for $i (text_to_list $text) {};, for[byte] $i $text {}; is a syntax sugar for for $i (text_to_list[byte] $text) {}; similar for[codepoint].

Steffan153 commented 8 months ago

I think several of the language-specific tests need updated, as they still have the old for $i $a $b in them