The following words are reserved by the language. You cannot use them as variable names, function names, or identifiers.

Keyword Category Description
defFunctions / MethodsDefines a function or method
returnFunctions / MethodsReturns a value from a function
staticFunctions / MethodsMarks a method as class-level (no self)
classClassesDefines a new class
newClassesCreates an instance of a class
selfClassesRefers to the current instance inside a method
superClassesCalls the parent class constructor
ifControl FlowConditional branch
elifControl FlowAdditional conditional branch
elseControl FlowFallback branch when no condition matches
whileControl FlowLoop while condition is true
forControl FlowIterate over a list or range
inControl FlowUsed with for and membership tests
breakControl FlowExit the current loop immediately
continueControl FlowSkip to the next loop iteration
tryError HandlingStart a guarded block
catchError HandlingHandle an error from a try block
throwError HandlingRaise an error
importModulesLoad a module or file
letVariablesDeclare a variable
trueLiteralsBoolean true value
falseLiteralsBoolean false value
nullLiteralsAbsence of a value
andLogicLogical AND
orLogicLogical OR
notLogicLogical NOT
printBuilt-inPrint a value to the console

Usage examples

 keywords.ks
# let — variable declaration
let x = 42

# def — function definition
def greet(name) {
    return "Hello, {$name}!"
}

# class / new / self
class Point {
    def new(x, y) {
        self.x = x
        self.y = y
    }
}
let p = new Point(3, 4)

# if / elif / else
if x > 50 {
    print("big")
} elif x > 20 {
    print("medium")
} else {
    print("small")
}

# for / in
for i in range(3) {
    print(i)
}

# try / catch / throw
try {
    throw "oops"
} catch (e) {
    print(e)
}

# import
import math
print(math.pi)

# and / or / not / true / false / null
let flag = true and not false
print(flag)