Skip to main content

Datatypes

This page describes the data values Semantifyr can represent: primitives, value-typed records, and enumerations.

Primitive Datatypes

The standard library declares the following primitive datatypes:

TypeDescription
intInteger numbers
boolBoolean values: true or false
realReal numbers
stringSequences of characters

Backend support varies. See Standard Library / Backend support for which primitives the Theta backend handles.

Enumerations

An enum declares a type with a fixed set of named literals.

enum Color {
Red,
Green,
Blue
}

Enum literals are referenced with :::

if (current == Color::Red) {
current := Color::Green
}

Records

Records are value-typed objects. They have no identity: two records with equal field values are interchangeable. Records are analogous to Java Valhalla value classes or C structs. Records have no inheritance and no behavior; they only carry data.

record Point {
var x: int
var y: int
}

A record literal lists the fields by name inside curly braces:

var origin: Point := Point {
x = 0,
y = 0
}

For an identity-bearing alternative, see Classes.