渲染zh-Hant

之前

Translation status: 繁體中文 reader-locale proof. Term names and code fences follow the zh-Hant pack; supporting prose may still be English.

Creates an exclusive range with a Latin keyword.

Syntax: <expression> 之前 <expression>

Category#

range

Examples#

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

Creates an exclusive range with a Latin keyword.

# =============================================================================
# 之前 — Creates an exclusive range with a Latin keyword.
# =============================================================================
#
# What this teaches:
#   • Exclusive range iteration — `範圍 <initium> 之前 <finis>` iterates from
#     initium up to (but not including) finis
#   • Range keyword pattern — `之前` provides a natural-language alternative
#     to symbolic range syntax
#
# Common mistakes:
#   • confusing `之前` (exclusive upper bound) with `直到` (inclusive) — `0 之前 4` yields 0,1,2,3 while `0 直到 4` yields 0,1,2,3,4
#
# See also: 直到, ‥
# =============================================================================

# 之前 — exclusive upper bound for range iteration
#
# 遍歷 範圍 <initium> 之前 <finis> <var> { … }
#
# GRAMMAR:
#   iterStmt :← '遍歷' '範圍' expr '之前' expr binding '{' stmt* '}'
#
# EXPECTED OUTPUT:
#   none

main {
    # i = 0, 1, 2, 3 (stops before 4)
    for range 0 before 4 const i {
        print i
    }
}

Expected output:

0
1
2
3