Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Types

Solstice is statically typed, meaning all values must have a known type before any code can be executed.

Core Types

These core types are automatically avaliable in Solstice. The words to identify them are reserved and cannot be reassigned.

int

8-byte signed integer, equivalent to C int64_t or Ground -int.

Examples: 32, 121, -5

double

8-byte double prescision floating point number, equivalent to C double or Ground -double.

Examples: 3.14, -2.7

string

C-style null-terminated array of characters. Equivalent to C char* or Ground -string.

char

1-byte signed integer, usually used to store a character, however can also be used to store bytes. Equivalent to C char or Ground -char.

bool

1-byte unsigned integer, either 1 or 0. Represented by the reserved words true and false. Equivalent to C char (no stdbool.h) or bool (with stdbool.h) or Ground -bool.

Combined Types

These types utilise core types to create new combinations. They take type arguments.

fun

Represents a function. Equivalent to Ground -function, or a C function pointer.

Syntax:

fun(...) type

where:

  • type is a type identifier, which will be the return type
  • ... is multiple type identifiers, seperated by commas, which are the argument types

Example:

fun(int, string) bool

This represents a function which takes an int and string as arguments, and returns a bool.

template

Represents an uninitialized object. Equivalent to Ground -struct.

Syntax:

template(...)

where ... is multiple pairs of:

  • a type identifier for the field, and
  • an identifier (representing the field name)

seperated by commas.

Example:

template(int x, string y)

This represents a template which, when initialized, has fields x (with integer) and y (with string).

object

Represents an initialized object.

Syntax:

object(...)

where ... is multiple pairs of:

  • a type identifier for the field, and
  • an identifier (representing the field name)

seperated by commas.

Example:

object(int x, string y)

This represents a object which has fields x (with integer) and y (with string).