Files
Nim/tests/lexer/tunicode_operators.nim
Emmanuel M. Smith🔸 27763495bc lexer: add seven more unicode operators (#26074)
closes nim-lang/RFCs#571

Adds `⟑ ⟇ ⩓ ⩔ ■ □ ☆` with the same priority as `*`.

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2026-08-05 16:12:17 +02:00

40 lines
780 B
Nim

#{.experimental: "unicodeOperators".}
proc `⊙`(x, y: int): int = x * y
proc `⊙=`(x: var int, y: int) = x *= y
proc `⊞++`(x, y: int): int = x + y
const a = 9
var x = 45
x ⊙= a⊞++4⊙3
var y = 45
y *= 9 + 4 * 3
assert x == y
proc `⟑`(x, y: int): int = x * y
proc `⟇`(x, y: int): int = x * y
proc `⩓`(x, y: int): int = x * y
proc `⩔`(x, y: int): int = x * y
proc `■`(x, y: int): int = x * y
proc `□`(x, y: int): int = x * y
proc `☆`(x, y: int): int = x * y
proc `★`(x, y: int): int = x * y
assert 2 + 3 ⟑ 4 ⟇ 5 ⩓ 6 ⩔ 7 ■ 8 □ 9 ☆ 10 ★ 11 == 2 + 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11
proc `⟑=`(x: var int, y: int) = x *= y
proc `⩓++`(x, y: int): int = x * y
var z = 45
z ⟑= a⩓++4⟑3
var w = 45
w *= 9 * 4 * 3
assert z == w