Variables & Constants

In Astra, variables are dynamically typed — you don't need to declare a type. Just assign a value and Astra figures out the rest.

Variables

Assign a value using =. No var, let, or def needed.

variables.astra
x = 10 name = "Astra" pi = 3.14159 flag = true write x \\ 10 write name \\ Astra write pi \\ 3.14159 write flag \\ TRUE

Variables can be reassigned to any type at any time:

x = 10 write x \\ 10 x = "hello" write x \\ hello x = true write x \\ TRUE

Constants

Use const to declare a constant — a value that cannot be changed after assignment.

constants.astra
const MAX = 100 const PI = 3.14159 const APP_NAME = "Astra" write MAX \\ 100 write PI \\ 3.14159
⚠️ Note: Attempting to reassign a constant will throw a compile-time error.
const X = 10 X = 20 \\ Error: Cannot reassign constant variable

Data Types

Astra supports the following data types:

TypeExampleDescription
Integerx = 42Whole numbers (64-bit)
Floatx = 3.14Decimal numbers
Stringx = "hello"Text in double quotes
Booleanx = truetrue, false, or maybe
Pointerp = adr(x)Memory address of a variable
types.astra
\\ Integer age = 25 big = 9999999999 \\ Float pi = 3.14159 temp = -2.5 \\ String name = "Astra" greeting = "Hello, " + name \\ Boolean active = true done = false write age \\ 25 write big \\ 9999999999 write pi \\ 3.14159 write greeting \\ Hello, Astra write active \\ TRUE

Tri-state Boolean

Astra's boolean system has three states — true, false, and maybe. This is unique to Astra and useful for representing uncertainty.

tristate.astra
x = true y = false z = maybe write x \\ TRUE write y \\ FALSE write z \\ MAYBE \\ Boolean logic write x && y \\ FALSE write x || y \\ TRUE write !x \\ FALSE \\ Comparison write x == true \\ TRUE write z == maybe \\ TRUE
💡 Tip: maybe is perfect for representing uncertain or pending states — like a task that is neither complete nor incomplete.

Multi-Assignment

Assign multiple variables in a single line:

multi.astra
a, b, c = 10, 20, 30 write a \\ 10 write b \\ 20 write c \\ 30

Range Assignment

Assign a range of values to a range of variables using --:

range.astra
\\ Assign a=1, b=2, c=3, d=4, e=5 a--e = 1--5 write a \\ 1 write b \\ 2 write c \\ 3 write d \\ 4 write e \\ 5

Operators

Increment & Decrement

x = 5 x++ write x \\ 6 x-- write x \\ 5

Compound Assignment

x = 10 x += 5 \\ x = x + 5 = 15 write x x -= 3 \\ x = x - 3 = 12 write x

Alias

Create an alias for a variable — useful for sharing global variables inside functions:

score = 100 alias tempscore \\ Inside functions, tempscore works as local copy #f update() tempscore = tempscore + 10 write tempscore \\ 110 #ef update() write score \\ 100 — unchanged

Variable Inspector

Use info to inspect a variable at runtime:

x = 42 info x
======================================== Astra Variable Inspector ======================================== Variable Name : x Memory Index : 0 Initialized : YES Data Type : Integer Current Value : 42 ========================================