Fix Game of Life example compilation (#72)#89
Merged
associate-1 merged 2 commits intomainfrom Feb 23, 2026
Merged
Conversation
Three transpiler bugs fixed: - VAL [n]TYPE abbreviations generated wrong Go type (int instead of []int) - ALT guard channels hardcoded to chan int regardless of actual channel type - Added chanElemTypes tracking to resolve channel element types from declarations and proc parameters Adapted life.occ to remove dependencies on the "Programming in occam 2" book standard library (write.string, write.formatted, DATA.ITEM protocol) by defining inline helper PROCs and rewriting ANSI escape output directly. Added terminal.keyboard/terminal.screen channel declarations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
dboreham
approved these changes
Feb 23, 2026
Wrap the main body in PROC life (CHAN BYTE keyboard?, screen!, error!) so the transpiler generates the stdin/stdout/stderr harness automatically. Add channel direction annotations to all PROCs that pass through the keyboard/screen channels. Fix ALT guard variables to use <-chan (receive-only) instead of chan (bidirectional), since ALT always receives. This allows directional channels from the entry harness to be assigned to guard variables. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
dboreham
approved these changes
Feb 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
VAL [n]TYPEabbreviation codegen:VAL [8]INT nx IS [...]was generatingvar nx int = []int{...}— now correctly generatesvar nx []int = []int{...}. AddedIsFixedArrayflag to ASTAbbreviationstruct, propagated through parser and both codegen paths.var _alt0 chan int = nilregardless of actual channel type. AddedchanElemTypesmap to track channel element types from declarations and proc parameters, used during ALT codegen.life.occ: Replaced dependencies on the "Programming in occam 2" book standard library (write.string,write.formatted,DATA.ITEMprotocol,data.int) with inline helper PROCs and direct ANSI escape byte output. Addedterminal.keyboard/terminal.screenchannel declarations.The program now transpiles and passes
go vetcleanly.Test plan
go test ./...)./occam2go -o /tmp/life.go historical-examples/life.occtranspiles without errorsgo vet /tmp/life.gopasses🤖 Generated with Claude Code