corx


A statically typed, general-purpose programming language, crafted for simplicity and performance.

"Trust the programmer" - corx








# Declaration

A variable can be declared without a value. If no value is assigned, it contains a garbage value (data previously present in the memory location). Always assign a value before using a variable to avoid undefined behavior.


int num;     # num contains garbage value
float speed; # speed contains garbage value
string name; # name contains garbage value
        

# Multiple declaration

Variables of the same type can be declared together. Each variable will have its own garbage value until explicitly initialized.


int num, count;      # num, count contains garbage value
float speed, height; # speed, height contains garbage value
string name, email;  # name, email contains garbage value
         

# Declaration then initialization

Variables can be declared first and initialized later.


int num;
float speed;
string name;

num = 5;              # num is now assigned the value 5
speed = 20.0;         # speed is now assigned 20.0
name = "John Coffee"; # name is now initialized
        

# Declaration and initialization

Variables can be declared and initialized in one statement.


int num = 5;                 # num is initialized to 5
float speed = 20.0;          # speed is initialized to 20.0
string name = "John Coffee"; # name is initialized with a string
        

# Multiple declaration and initialization

Variables of the same type can be declared together, each with its own initial value.


int width = 20, height = 10; # width and height are initialized to 20 and 10, respectively
        

# Constant

A constant is a value that cannot be changed once it is assigned. In corx, constants are declared using the const keyword.

Constants are useful for representing values that should remain constant throughout the program, such as mathematical constants or fixed configuration values. Any attempt to modify a constant will result in a compile-time error.


const pi = 3.1416; # can not be changed once declared
        

A constant cannot be declared without initialization. In other words, it cannot be created without a value.