Skip to content
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

Document if, for, while and numeric range in spec #89

Open
juliaogris opened this issue Mar 26, 2024 · 1 comment
Open

Document if, for, while and numeric range in spec #89

juliaogris opened this issue Mar 26, 2024 · 1 comment

Comments

@juliaogris
Copy link
Member

juliaogris commented Mar 26, 2024

Add specification of if, for and while statements.

if: document nested if's and what the else binds to.
document if else

There are 3 types of for ... range statements, to be spec'ed more clearly:

  • numeric step range
  • ranging over array elements
  • ranging over map keys

There is an arguable inconsistency with for ... range:
numeric step range: Evaluated once at beginning (similar to python)
arrays / maps: can be modified while iterating over them and may change iteration count, map example

numeric step range results may appear confusing for (see discord discussion ):

x := 1
for i := range x-1 x+5 1
    x = x + 1
    print i
end
print "\nx: " x
@juliaogris juliaogris added this to the 🚸 Learn v0.2.0 milestone Mar 26, 2024
@Rossiar
Copy link

Rossiar commented Apr 19, 2024

We should also add a 4th case for ranging over a string, which is also currently missing from the syntax by example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

2 participants