Data Types

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

Acton supports a plethora of primitive 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
  • bool boolean, like True or False
  • str strings, like foo
    • strings support Unicode characters
  • lists like [1, 2, 3] or ["foo", "bar"]
  • dictionaries like {"foo": 1, "bar": 3}
  • tuples like (1, "foo")
  • sets like {"foo", "bar"}

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