lang F1: range-based for + inline-for unroll over packs
Add range loop syntax:
- runtime for start..end (i) { } counting loop, cursor optional, end exclusive
- comptime inline for start..end (i) { } comptime-unrolled body
The inline form binds the cursor as an int_val comptime constant per
iteration, so xs[i] over a heterogeneous pack substitutes the concrete
per-position element -- the canonical's pack-iteration vehicle
(inline for 0..sources.len (i) { sources[i].addListener(...) }).
- AST: ForExpr.range_end, ForExpr.is_inline
- parser: parseForExpr range vs collection form; suppress_call flag so
N (i) is not read as a call N(i) while parsing a range bound
- lower: lowerRuntimeRangeFor / lowerInlineRangeFor; evalComptimeInt;
comptimeIndexOf extends pack-index resolution beyond int literals
Revises spec's inline for i in 0..N to the no-in, range-first, paren-cursor
form. Regression: examples/200-for-range.sx.
This commit is contained in:
1
tests/expected/200-for-range.exit
Normal file
1
tests/expected/200-for-range.exit
Normal file
@@ -0,0 +1 @@
|
||||
0
|
||||
10
tests/expected/200-for-range.txt
Normal file
10
tests/expected/200-for-range.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
i=0
|
||||
i=1
|
||||
i=2
|
||||
n=5
|
||||
j=2
|
||||
j=3
|
||||
j=4
|
||||
[0]=A
|
||||
[1]=B
|
||||
[2]=A
|
||||
Reference in New Issue
Block a user