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
or1267650600228229401496703205376
int
is arbitrary precision and can grow beyond machine word sizesi16
,i32
,i64
,u16
,u32
,u64
are fixed size integers
float
64 bit float, like1.3
or-382.31
bool
boolean, likeTrue
orFalse
str
strings, likefoo
- 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 |
|
this will print the global foo |
|
set a local variable with the name foo, shadowing the global constant foo |
|
print local foo, then call printfoo() |
|
Output:
local foo, shadowing the global foo: 4
global foo: 3
u16: 1234