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

Data Types

Every value in Acton is of a certain type. The type specifies what kind of data is being specified and how to work with that data. Acton has a number of built-in data types.

  • integers, like 1, 2, 123512, -6542 or 1267650600228229401496703205376
    • int is arbitrary precision and can grow beyond machine word sizes
    • i16, i32, i64, u16, u32, u64 are fixed size integers
  • float 64 bit float, like 1.3 or -382.31
  • complex complex numbers like 1+2j
  • bool boolean, like True or False
  • str strings, like foo
    • strings support Unicode characters
  • tuples for structuring multiple values, like (1, "foo") or (a="bar", b=1337)

In Acton, mutable state can only be held by actors. Global definitions in modules are constant. Assigning to the same name in an actor will shadow the global variable.

module level constant
foo = 3
this will print the global foo
def printfoo():
    print("global foo:", foo)
set a local variable with the name foo, shadowing the global constant foo
actor main(env):
    foo = 4
print local foo, then call printfoo()
    print("local foo:", foo)
    printfoo()

    a = u16(1234)
    print("u16:", a)

    env.exit(0)

Output:

local foo, shadowing the global foo: 4
global foo: 3
u16: 1234