Keywords
Reserved words with special meaning in KelpyShark.
The following words are reserved by the language. You cannot use them as variable names, function names, or identifiers.
| Keyword | Category | Description |
|---|---|---|
def | Functions / Methods | Defines a function or method |
return | Functions / Methods | Returns a value from a function |
static | Functions / Methods | Marks a method as class-level (no self) |
class | Classes | Defines a new class |
new | Classes | Creates an instance of a class |
self | Classes | Refers to the current instance inside a method |
super | Classes | Calls the parent class constructor |
if | Control Flow | Conditional branch |
elif | Control Flow | Additional conditional branch |
else | Control Flow | Fallback branch when no condition matches |
while | Control Flow | Loop while condition is true |
for | Control Flow | Iterate over a list or range |
in | Control Flow | Used with for and membership tests |
break | Control Flow | Exit the current loop immediately |
continue | Control Flow | Skip to the next loop iteration |
try | Error Handling | Start a guarded block |
catch | Error Handling | Handle an error from a try block |
throw | Error Handling | Raise an error |
import | Modules | Load a module or file |
let | Variables | Declare a variable |
true | Literals | Boolean true value |
false | Literals | Boolean false value |
null | Literals | Absence of a value |
and | Logic | Logical AND |
or | Logic | Logical OR |
not | Logic | Logical NOT |
print | Built-in | Print 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)