-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Description
The parser does not support replicated ALT blocks (ALT i = 0 FOR n), analogous to the already-supported replicated SEQ, PAR, and IF constructs.
Syntax
ALT i = 0 FOR n.inputs
BYTE ch:
in[i] ? ch
SEQ
out ! ch
This creates n.inputs alternatives, each guarded by in[i] ? ch, and selects whichever channel is ready first.
Affected files
kroc/modules/course/examples/sort_pump.occ(line 184)kroc/modules/course/examples/sort_pump_2.occ(line 184)kroc/modules/course/examples/sort_inside.occ(line 213)kroc/modules/course/examples/sort_inside_2.occ(line 224, 294)kroc/modules/course/examples/bar.occ(lines 327, 338, 352)
This is the single most impactful missing feature — it blocks 5 out of 16 example files.
Current error
sort_pump.occ:184: expected indented block after ALT
sort_pump.occ:184: unexpected token: =
The parser sees ALT and expects an indented block of alternatives, but instead finds the replicator syntax i = 0 FOR n.
Proposed Go mapping
// ALT i = 0 FOR n → select over dynamically built cases
// Requires reflect.Select for runtime-variable number of casesSince Go's select requires statically known cases, the replicated ALT will need reflect.Select to build the case list dynamically at runtime:
cases := make([]reflect.SelectCase, n)
for i := 0; i < n; i++ {
cases[i] = reflect.SelectCase{Dir: reflect.SelectRecv, Chan: reflect.ValueOf(in[i])}
}
chosen, value, _ := reflect.Select(cases)
ch := byte(value.Int())
// ... body using chosen as iRelated
- Course examples: unimplemented features preventing transpilation #43 - Course examples tracking issue
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels