Verse is a strongly-typed programming language, which means a type is assigned to every identifier. With strong typing, code won't produce unpredictable results during runtime because the types for identifiers are known, along with how operations affect those types.
There are instances where the type is not explicitly required, such as when creating a constant. In the example MyConstant := 0
, the type for MyConstant
is inferred to be int because an integer value is assigned to it even though the int
type wasn’t explicitly provided. In instances like this, the type is inferred.
Verse has built-in types that support the fundamental operations most programs need to perform. You can create your own types by combining these into larger structures, but these common types are important to understand as the foundation for using variables and constants in Verse.
The following pages describe the common types of Verse:
Logic
The logic type represents the Boolean values true and false.
Int
The int type represents integer (non-fractional number) values.
Float
The float type represents all non-integer numerical values. It can hold large values and precise fractions.
String
The string type represents non-numerical values like words, names, sentences, and other collections of characters.
Rational
The rational type is used as the result of integer division.
Any
Any is the supertype of all types, meaning whatever behavior is defined for it is also defined for all the any subtypes.
Comparable
A subtype of any, comparable adds the requirement that any value of this type can be compared to any other value of this type.
Void
The void type can only be used as a return type of a function and indicates that the result of the function is not useful.