Skip to content

Core Types

These are the basic data types that you’ll see anywhere that solus runs, there are also usertypes, but those are up to whatever application embeds the VM to provide.

fun

A compiled solus function, represented by either bytecode or a C function pointer for API calls. The function call syntax in solus is very conventional, but the function definition syntax may be a little unique for new users. A function in solus is defined first by its captures [a, b, c], then its arguments (a, b, c), and then the function body as a block. Upvalues are automatically promoted so that their lifetime is at least as long as the function, and do not need to be passed as arguments to reference them.

Example

solus
var x = 4;
var local = [x](a) { # [captures](args)
    x += a;
};
var(2);
io.println(x); # 6

Note: You may also see captures referred to as “upvalues.” This is the formal name used internally in the VM.

obj

An object type, this functions very similarly to tables in Lua or objects in JavaScript. All objects are references and to make a copy of an object you must construct a new one. Two objects can be joined into a new one by using +, and += will append members or array elements to an object.

Operators

OperatorTypesDescription
. []strMember Access
+objJoin (new)
+=objJoin (append)
-=strDelete member

Construction

solus
var local = {
    member = 2
    other_member = 3, # Optional commas
};

Concatenation

solus
var obj = {};
obj += { x = 2 }; # Same obj as before

str

The string type of solus, this type is very simple to work with and lends itself naturally to programmers’ expectations. It does not require any special functions or operators for concatenation.

Operators

OperatorTypesDescription
+strConcatenation

Construction

solus
var local = "str";

i64

A 64 bit integer, the only integer type supported by solus natively. Although, this may change in the future.

Operators

OperatorTypesDescription
+i64 f64Add
-i64 f64Subtract/Negate
*i64 f64Multiply
/i64 f64Divide

Construction

solus
var local = 1;

f64

A 64 bit floating point number, the only floating point type supported by solus natively. Although, this may change in the future.

Operators

OperatorTypesDescription
+f64 i64Add
-f64 i64Subtract/Negate
*f64 i64Multiply
/f64 i64Divide

Construction

solus
var local = 3.14;

bool

A value that can only be true (1) or false (0).

Operators

OperatorDescription
! -Invert

Construction

solus
var local = true;
var nvar = !local; # false

err

A type representing a failure condition, containing a string for the reason. This is for result-like error handling in solus, without the need for protected calls.

Construction

solus
var local = err("Error!");

panic

A type that the user cannot handle themselves, a panic is solus’ form of exceptions. Unless caught in a protected call, this will exit the program and show the line where it originated. When caught by catch or attempt, it will be transformed into the err type.

Construction

solus
panic("Critical Failure");