Location: src/lang/Expr.h (ListCompExpr/ListCompBody), src/lang/Parser.cpp (comprehension parsing), src/lang/Interpreter.cpp (evaluation).
Real OpenSCAD's list-comprehension for clause supports:
- multiple variables in one clause:
[for (i=[0:2], j=[0:2]) i*3+j]
- C-style
for(init; cond; next): [for (i=0, x=1; i<5; i=i+1, x=x*2) x]
- nested
for clauses within one bracket: [for (i=a) for (j=b) i+j]
ListCompExpr/ListCompBody (Expr.h) are explicitly single-variable only today, so all three forms fail to parse. Note this is specifically about the expression form ([for (...) ...]) — the statement form (for () { ... }, CsgEvaluator's ForNode) already supports multi-variable clauses as of a prior fix (see closed issue #90's "for-nested-tests" work), which used a different AST path (ForClause list). This gap needs the equivalent treatment applied to ListCompBody.
Why this matters for real-world scripts: OpenSCAD has no mutable state, so C-style for is the idiomatic way to do accumulator-style math (running sums/products) inside a comprehension. Multi-variable comprehensions are a common pattern for generating grids/matrices. Both show up in intermediate-to-advanced .scad scripts and libraries, not just edge-case test files.
Originally noted as a deferred gap in docs/roadmap.md (now trimmed); filing as a tracked issue instead.
Location:
src/lang/Expr.h(ListCompExpr/ListCompBody),src/lang/Parser.cpp(comprehension parsing),src/lang/Interpreter.cpp(evaluation).Real OpenSCAD's list-comprehension
forclause supports:[for (i=[0:2], j=[0:2]) i*3+j]for(init; cond; next):[for (i=0, x=1; i<5; i=i+1, x=x*2) x]forclauses within one bracket:[for (i=a) for (j=b) i+j]ListCompExpr/ListCompBody(Expr.h) are explicitly single-variable only today, so all three forms fail to parse. Note this is specifically about the expression form ([for (...) ...]) — the statement form (for () { ... },CsgEvaluator'sForNode) already supports multi-variable clauses as of a prior fix (see closed issue #90's "for-nested-tests" work), which used a different AST path (ForClauselist). This gap needs the equivalent treatment applied toListCompBody.Why this matters for real-world scripts: OpenSCAD has no mutable state, so C-style
foris the idiomatic way to do accumulator-style math (running sums/products) inside a comprehension. Multi-variable comprehensions are a common pattern for generating grids/matrices. Both show up in intermediate-to-advanced.scadscripts and libraries, not just edge-case test files.Originally noted as a deferred gap in
docs/roadmap.md(now trimmed); filing as a tracked issue instead.