Renderingen-US

default

Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.

Starts the default branch of an switch or match statement.

Aliases: default

Syntax: default <block>

Category#

control-flow

Examples#

radix/corpus/ceterum/ceterum.fab (canonical · keyword)#

Starts the default branch of an switch or match statement.

# =============================================================================
# default — Starts the default branch of an switch or match statement.
# =============================================================================
#
# What this teaches:
#   • Default arm — `default <block>` is the catch-all branch in an `switch`
#     or `match` match expression
#   • Fallback handling — when no `case` pattern matches, execution falls
#     through to the `default` block
#
# Common mistakes:
#   • using `default` with `match all` — `all` forbids catchall arms and requires listing every variant explicitly (SEM044)
#
# See also: switch, match
# =============================================================================

# default — default switch arm
#
# GRAMMAR:
#   defaultClause :← 'default' block
#
# EXPECTED OUTPUT:
#   Scalar stdout smoke (see body).
#
# BACKEND:
#   Cross-ref: switch/ceterum.fab.
#

main {
    const _ tag ← "z"
    switch tag {
        case "a" { print "a" }
        default { print "default" }
    }
}

Expected output:

default