Variables

legionhjyu has two ways to declare a variable and one way to reassign.

forge — mutable variable

lhj
forge x = 42
forge name = "Aria"
forge items = [1, 2, 3]
forge score = 0.0

You can optionally add a type hint after the name:

lhj
forge x: int     = 42
forge name: str  = "Aria"
forge flag: yep  = nope

Type hints are not enforced at runtime. They're there for readability and tool support.

lock — constant

lhj
lock PI       = 3.14159
lock MAX_SIZE = 1000
lock APP_NAME = "legionhjyu"

Trying to reassign a lock variable raises an error:

lhj
lock X = 10
X <- 20   ## RuntimeError: cannot reassign constant 'X'

Arrow assignment <-

After a variable is declared with forge, you reassign it with <- or =:

lhj
forge x = 1
x <- 99
x = 50

Both 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:

lhj
forge a = 1
forge b = 2
forge c = a + b   ## 3

Scope

Variables follow lexical scope. A variable declared inside a blade, ritual, or march block is local to that block:

lhj
forge x = "outer"

blade test():
    forge x = "inner"
    echo x        ## inner

test()
echo x            ## outer

To read an outer variable from inside a function, just reference it — no special syntax:

lhj
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.

lhj
forge my_var = 1
forge myVar  = 2
forge _temp  = 3

Reserved words (forge, blade, ritual, march, etc.) can't be used as variable names.