// Five Go Extensions — All 9 new syntax features IMPORT "strings" IMPORT "fmt" PROCEDURE Main() LOCAL cName, nAge, cResult, cUpper, cCity LOCAL aData, aSub, i LOCAL db, err cName := "Charles" nAge := 30 cCity := "Seoul" ? "=== Five Go Extension Syntax ===" ? // 1. Multi-Return: a, b := Func() ? "[1] Multi-Return" cUpper, cResult := strings.ToUpper("hello"), strings.ToLower("WORLD") ? " upper:", cUpper, " lower:", cResult // 2. DEFER — auto cleanup ? "[2] DEFER" TestDefer() // 3. Slice syntax: a[low:high] ? "[3] Slice" aData := {"alpha", "beta", "gamma", "delta", "epsilon"} aSub := aData[2:4] ? " aData[2:4]:", aSub[1], aSub[2] aSub := aData[3:] ? " aData[3:]:", aSub[1], aSub[2] aSub := aData[:2] ? " aData[:2]:", aSub[1] // 4. Parallel assignment: a, b := b, a ? "[4] Parallel / Swap" cUpper, cResult := cResult, cUpper ? " swapped:", cUpper, cResult // 5. Blank identifier _ ? "[5] Blank _" _, cResult := "discard", "keep" ? " _,keep:", cResult // 6. SWITCH (existing + compatible) ? "[6] SWITCH" SWITCH nAge CASE 20 ? " twenty" CASE 30 ? " thirty" OTHERWISE ? " other" ENDSWITCH // 7. CONST block ? "[7] CONST" CONST STATUS_ACTIVE := 1 STATUS_CLOSED := 2 STATUS_PENDING := 3 END CONST ? " CONST defined" // 8. Nil-safe: obj?:Method() ? "[8] Nil-safe ?:" db := NIL cResult := db?:Close() ? " nil?:Close():", cResult, "(no crash!)" // 9. String interpolation: f"..." ? "[9] f-string" cResult := f"Name: {cName}, Age: {nAge}, City: {cCity}" ? " ", cResult ? ? "=== All Extensions OK ===" RETURN PROCEDURE TestDefer() LOCAL cStatus cStatus := "open" DEFER QOut(" [defer] cleanup!") cStatus := "processing" ? " working..." cStatus := "done" RETURN