corx


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

"Trust the programmer" - corx








# Type Metadata

Due to performance reasons, type metadata is only available to specific contexts (where metadata is available) and some operations are only permitted in these contexts. For specific types, there are equivalent metadata types. As, for describing variadic function arguments there is a vargs type.


# typeof Operator

Retrieves the type ID of a given variable or expression. Useful for runtime type inspection in contexts where type metadata is available.


int x = 42;

if (typeof x == type_int) {
    print("x is an integer.");
}
        

# typestr Operator

Converts a type ID into its string representation for debugging or user feedback purposes.


int x = 42;

print("Type of x: " + typestr typeof x);  # Output: "Type of x: integer"

# or for clarity
print("Type of x: " + typestr(typeof x));
        

# foreach Loop

Simplifies iteration over collections or metadata structures like vargs. Works with arrays, metadata types, and other iterable structures.


int sum(int args...) {         # variable name, only int type is allowed
    vargs data = vainit(args);

    int res = 0;

    foreach (arg in data) {
        print(arg);
    }

    # automatic cleanup any data existed

    return res;
}