Skip to content

Conversation

@jnthn
Copy link
Collaborator

@jnthn jnthn commented Jan 6, 2026

For loops mostly use the Raku syntax (-> style), however since our if and given all currently require parens around the condition or topic, we require them here too for consistency. We allow multiple loop variables for iterating two items at a time.

For hashes, we do a key/value iteration, so you iterate the two at once and put them into separate variables. This isn't quite Perl or Raku, but it is the path of least resistance from what we have today to getting something useful. (We also don't go down the path of sigils beyond the existing $.)

Finally, array literals like [1, 2] are also introduced. They can be used directly with for or assigned to a variable. There are no other operations on arrays for now; they are introduced primarily in support of for.

An example just like the request in #600 is included among the tests, to make sure we can handle that use case.

For loops mostly use the Raku syntax (`->` style), however since our
`if` and `given` all currently require parens around the condition or
topic, we require them here too for consistency. We allow multiple loop
variables for iterating two items at a time.

For hashes, we do a key/value iteration, so you iterate the two at once
and put them into seperate variables. This isn't quite Perl or Raku, but
it is the path of least resistance from what we have today to getting
something useful. (We also don't go down the path of sigils beyond the
existing `$`.)

Finally, array literals like `[1, 2]` are also introduced. They can be
used directly with `for` or assigned to a variable. There are no other
operations on arrays for now; they are introduced primarily in support
of `for`.
@jnthn jnthn requested a review from zaucker January 6, 2026 17:05
Copy link
Contributor

@zaucker zaucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll merge and have asked Christoph to have a look if he sees any additional features that might be useful.

@zaucker zaucker merged commit 0d7dd97 into main Jan 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants