Variables
legionhjyu has two ways to declare a variable and one way to reassign.
forge — mutable variable
forge x = 42
forge name = "Aria"
forge items = [1, 2, 3]
forge score = 0.0You can optionally add a type hint after the name:
forge x: int = 42
forge name: str = "Aria"
forge flag: yep = nopeType hints are not enforced at runtime. They're there for readability and tool support.
lock — constant
lock PI = 3.14159
lock MAX_SIZE = 1000
lock APP_NAME = "legionhjyu"Trying to reassign a lock variable raises an error:
lock X = 10
X <- 20 ## RuntimeError: cannot reassign constant 'X'Arrow assignment <-
After a variable is declared with forge, you reassign it with <- or =:
forge x = 1
x <- 99
x = 50Both work. The <- form is idiomatic for reassignment.
Multiple assignment
legionhjyu doesn't have tuple unpacking syntax yet, but you can assign to multiple variables in sequence:
forge a = 1
forge b = 2
forge c = a + b ## 3Scope
Variables follow lexical scope. A variable declared inside a blade, ritual, or march block is local to that block:
forge x = "outer"
blade test():
forge x = "inner"
echo x ## inner
test()
echo x ## outerTo read an outer variable from inside a function, just reference it — no special syntax:
forge count = 0
blade increment():
count <- count + 1 ## reads and writes outer 'count'Naming rules
Variable names can contain letters, digits, and underscores. They must start with a letter or underscore. Names are case-sensitive.
forge my_var = 1
forge myVar = 2
forge _temp = 3Reserved words (forge, blade, ritual, march, etc.) can't be used as variable names.