argotorg / argotorg/solidity

Range based loops

Open
#10,162 13 comments 4 reactions 0 assignees View on GitHub
high impact language design :rage4: medium effort must have
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
2d 19h
Merged PRs (30d)
29

Description

Range based loops were discussed several times, including at the Solidity Summit (#9054), in #4596, and in #9117.

Main motivation is improving code for analysis and reducing gas cost of checked array access.

This is a dedicated issue discussing the syntax and semantics:
```solidity
uint[] array;

for (uint value: array) {}

// And with slicing
for (uint value: array[start:end]) {}
```

Of course for value types this doesn't support references, but references/pointers is probably something we should solve separately in general.

Contributor guide

Open the contributing guide

Research direction

Review the prior discussions in #9054, #4596, and #9117 before attempting implementation. Define the syntax and semantics for range-based loops and array slicing, including the stated value-type limitation; the work is done when the language behavior and implementation scope are agreed and validated.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, solidity
Domain
blockchain, compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.