Skip to content

Hello! 👋 My name is Nathan Weir. This is a fun personal project for using AI to build a bespoke, domain-specific programming language. It is not a serious, professional project. This site and the language itself are largely generated via Claude Code. If you find yourself programming with Weir, have fun - but use at your own risk!

Reserved Words

This page lists all reserved words and special identifiers in Weir. These cannot be used as variable or function names.

KeywordPurposeExample
defnFunction definition(defn add ((x : i32) (y : i32)) : i32 (+ x y))
deftypeSum type (enum) definition(deftype (Option 'a) (Some 'a) None)
defstructProduct type (struct) definition(defstruct Vec2 (x : f64) (y : f64))
defclassTypeclass definition(defclass (Show 'a) (show : (Fn ['a] String)))
defmacroMacro definition(defmacro when (cond &body body) ...)
instanceTypeclass instance(instance (Show Vec2) (defn show ...))
declareSeparate type declaration(declare map (Fn [(Fn ['a] 'b) (List 'a)] (List 'b)))
KeywordPurposeExample
letLocal bindings(let ((x 5)) (+ x 1))
ifBinary conditional(if (> x 0) "yes" "no")
condMulti-branch conditional(cond ((< x 0) "neg") (else "pos"))
matchPattern matching(match opt ((Some x) x) (None 0))
whenSide-effect on true(when flag (println "yes"))
unlessSide-effect on false(unless done (continue))
fnLambda / closure(fn (x) (+ x 1))
doExplicit sequencing(do (step1) (step2) result)
set!Reassign mutable binding(set! x (+ x 1))
unsafeUnsafe block (for FFI)(unsafe (abs -42))
annType assertion(ann i32 42)
KeywordPurposeExample
pubPublic visibility(pub defn spawn ...)
mutMutable binding(let ((mut x 5)) (set! x 10))
elseDefault branch in cond(cond (...) (else default))
KeywordPurposeExample
importModule import(import math.vec2 (add sub))
externForeign function block(extern "C" (defn abs ...))
SymbolPurpose
->Thread-first macro
->>Thread-last macro
?Error propagation (postfix on Result)
.fieldField accessor (prefix dot)
KeywordPurposeExample
with-arenaArena allocation block(with-arena frame ...)

These identifiers are reserved as type names:

TypeDescription
i8, i16, i32, i64Signed integers
u8, u16, u32, u64Unsigned integers
f32, f64Floating point
BoolBoolean (true / false)
StringUTF-8 string
UnitUnit type (one value)
FnFunction type constructor
VectorVector type
AtomAtomic reference
ChannelTyped channel
PtrRaw pointer (FFI)
ResultError handling (prelude)
OrderingComparison result (prelude)
LiteralTypeDescription
trueBoolBoolean true
falseBoolBoolean false
None(Option 'a)Option empty variant
OkConstructorResult success
ErrConstructorResult error
SomeConstructorOption present
LTOrderingLess than
EQOrderingEqual
GTOrderingGreater than
ConventionMeaningExample
kebab-caseFunctions and variablesspawn-enemy, read-file
PascalCaseTypes and constructorsVec2, EnemyState, Some
:colon-prefixKeywords (values):name, :health
'quote-prefixType variables'a, 'elem
suffix!Mutating operationsset!, swap!
suffix?Predicates (return Bool)alive?, empty?