GSET
Language Guide

Control Flow

if/elif/else, match/case, and switch in GSET.

Implemented

if / elif / else

var score = 85
if score >= 90 {
    print("A")
} elif score >= 80 {
    print("B")
} else {
    print("C")
}

elif and else if are both accepted. Output:

TargetOutput
Pythonif score >= 90: / elif score >= 80: / else:
JavaScriptif (score >= 90) { … else if (score >= 80) { … else {

Nested blocks are indented correctly; braces are matched once per branch (regression-tested).

match / case

match evaluates a subject and jumps to the first case whose literal matches; default is the fallback:

var score = 85
match score {
    case 90:
        print("A")
    case 80:
        print("B")
    default:
        print("C")
}
TargetOutput
Pythonif score == 90: … elif score == 80: … else:
JavaScriptswitch (score) { case 90: … break; … default: … }

The Python and JavaScript paths are regression-tested against the parser-only-safety bugs of earlier versions.

switch

switch is parsed as a synonym and emits the same forms as match.

Expression conditions, not statements

Conditions can be any expression, including calls and comparisons:

if len(items) > 3 && is_open {
    print("go")
}

Parentheses in conditions are preserved.

On this page