Pelago
Core typesPrimitive types

Primitive types

The types built into the language: truth values, characters, integers and floats. One page per type.

A primitive type is built into the compiler. Its values are small, it is always copied rather than moved, and its methods come with the type, so nothing is imported to call x.abs() or c.isDigit().

Each type has its own page: what it is, how a value is written, every operator and method, what happens at the edges, and what is not finished.

TypeWhat it isPage
booltrue or false.bool
charOne Unicode scalar value.char
intThe default signed integer, 64 bits.int
int8, int16, int32Signed integers of a given width.int8, int16, int32
int64Another name for int.int64
uint8, uint16, uint32, uint64Unsigned integers of a given width.uint8, uint16, uint32, uint64
byte, uintOther names for uint8 and uint64.byte, uint
int128, uint128, int256, uint256Wide integers with the same checked arithmetic.int128, uint128, int256, uint256
floatThe default floating point number, 64 bits.float
float32, float16, float128, float256Other IEEE 754 binary formats.float32, float16, float128, float256

Overviews of the wide types: Wide integers and Wide and narrow floats.

Rules every primitive shares

  • Value semantics. Assigning, passing or returning a primitive copies it. There is no inout or sink to think about for a plain int.
  • No implicit conversions. int and float are never mixed silently. n to float is written out; see Conversions.
  • Checked arithmetic. An integer result that does not fit stops the program with stopped: arithmetic overflow. The % forms (+%, -%, *%) wrap on purpose.
  • Printing. Every primitive can be put in a #( ) string and passed to print.

On this page