Scope
Implements Phase 6 of docs/plans/collections.md.
Lower [expr for x in source if guard] to a stream-fused chain over source's iterator, written into a transient builder, sealed at the end.
Required work
- Grammar additions for the comprehension syntax (
LSQUARE expression FOR ID IN expression (IF expression)? RSQUARE).
make regenerate-parser.
- AST node for
ListComprehension.
- Builder + codegen lowering that emits an iterator chain → transient builder → seal.
- Tested examples in
compiler/examples/tested/basics/lists/.
Acceptance
[x*x for x in range(start: 1, end: 6)] evaluates to [1, 4, 9, 16, 25].
- The
if guard form lowers to a filter stage.
make ci green.
Origin
docs/plans/collections.md Phase 6 (deferred — grammar work pending Phase 5 patterns landing first, to avoid two grammar revisions in flight).
Scope
Implements Phase 6 of
docs/plans/collections.md.Lower
[expr for x in source if guard]to a stream-fused chain oversource's iterator, written into a transient builder, sealed at the end.Required work
LSQUARE expression FOR ID IN expression (IF expression)? RSQUARE).make regenerate-parser.ListComprehension.compiler/examples/tested/basics/lists/.Acceptance
[x*x for x in range(start: 1, end: 6)]evaluates to[1, 4, 9, 16, 25].if guardform lowers to afilterstage.make cigreen.Origin
docs/plans/collections.mdPhase 6 (deferred — grammar work pending Phase 5 patterns landing first, to avoid two grammar revisions in flight).