Control flow

blade — if/elif/else

blade handles conditional logic. The otherwise keyword is the else branch.

lhj
forge x = 10

blade x > 5:
    echo "big"
otherwise:
    echo "small"

Multi-branch:

lhj
forge score = 75

blade score >= 90:
    echo "A"
blade score >= 80:
    echo "B"
blade score >= 70:
    echo "C"
otherwise:
    echo "F"

Inline form (single-statement body on the same line):

lhj
blade x > 0: echo "positive"

march — loops

march handles both for-style and while-style loops.

For-each loop

lhj
forge items = ["sword", "shield", "potion"]

march item in items:
    echo item

Range loop

lhj
march i in 1..10:
    echo i          ## 1 through 10 inclusive

While loop

lhj
forge hp = 100

march hp > 0:
    echo "HP: {hp}"
    hp <- hp - 20

Loop with index

lhj
march i, item in enumerate(items):
    echo "{i}: {item}"

shatter — break

Exits the current loop immediately:

lhj
march i in 1..100:
    blade i == 5:
        shatter
    echo i
## prints 1 2 3 4

skip — continue

Skips to the next iteration:

lhj
march i in 1..10:
    blade i % 2 == 0:
        skip
    echo i          ## 1 3 5 7 9

pick — match/case

Pattern matching against values. Like a switch statement but more flexible.

lhj
forge status = "warrior"

pick status:
    case "warrior":
        echo "A fighter with sword and shield"
    case "mage":
        echo "A spellcaster with a staff"
    case "rogue":
        echo "A thief who strikes from shadows"
    otherwise:
        echo "Unknown class"

Matching on numeric ranges:

lhj
forge hp = 45

pick hp:
    case hp > 80:
        echo "healthy"
    case hp > 40:
        echo "wounded"
    otherwise:
        echo "critical"

Nested blocks

All control flow forms can be nested freely:

lhj
march i in 1..5:
    march j in 1..5:
        blade i == j:
            echo "diagonal: {i}"
        otherwise:
            skip

Inline blocks

Any block that contains a single statement can be written on the same line after the colon:

lhj
blade x > 0: echo "positive"
march i in 1..3: echo i

Multi-statement bodies still need indentation.