Aspen

A toy programming language

Types

Primitive Types

Aspen has the following built in datatypes:

TypeDescription
i6464 bit signed integer.
u6464 bit unsigned integer.
boolBoolean value.
stringA UTF-32 encoded string.
double64 bit floating point number.

Type Casting

Type casting can be done with function call syntax.

print i64(1.5);  // convert a double to i64
print double(3); // convert a i64 to double

Only type casting between numeric types (i64, u64, double) are allowed. Signed integers and floating point numbers can be converted to and from strings with the built in functions:

print itoa(3);      // i64    -> string
print ftoa(1.5);    // double -> string
print atoi("9");    // string -> i64
print atof("3.14"); // string -> double

These string conversion functions are useful for formatting output.

let name string = "Chris";
let age i64 = 23;
print name + " is " + itoa(age) + " years old.";