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

Built-in types and literals

Every value in Acton has a type.

Many values can be written directly in source code. These are called literals.

42, True, and "hello" are all literals: the value is written directly in the program instead of being computed somewhere else.

Common built-in types

TypeExampleNotes
int4264-bit signed integer
bigint123456789012345678901234567890arbitrary-precision integer
i8, i16, i32, u1, u8, u16, u32, u64u16(42)explicitly sized integers
float3.1464-bit floating-point number
complexcomplex.from_real_imag(1.0, 2.0)complex number
boolTrueTrue or False
str"hello"Unicode text
tuple(1, "two")fixed-size group of values
actor main(env):
    whole = 42
    huge = bigint(123456789012345678901234567890)
    ratio = 3.5
    truth = True
    name = "Acton"
    point = (x=3, y=4)
    z = complex.from_real_imag(2.0, 3.0)

    print(whole, huge, ratio, truth, name, point, z)
    env.exit(0)

Integer literals are not all the same internally. Small whole-number literals usually fit in int, while very large literals may need u64 or bigint. If the exact type matters, write it explicitly.

Choosing a type

Use:

  • int for ordinary whole numbers
  • bigint when whole numbers may grow beyond the normal int range
  • float for fractional values
  • bool for yes/no conditions
  • str for text
  • tuples for small fixed-size groups of values

Reach for fixed-size integers when width or sign matters, and for complex when you need real and imaginary parts together.

Lists, dictionaries, and sets are covered in Collections.

More detail