Define a named struct with type:
type Point = {Integer x, Integer y}
type Person = {String name, Integer age}
Use StructName { field: value, ... } to create an instance:
let p = Point { x: 10, y: 20 }
let alice = Person { name: "Alice", age: 30 }
print(alice.name) // Alice
print(alice.age) // 30
alice.age = 31
Prefix with $ or shared to make the whole struct shared across threads.
shared bob = Person { name: "Bob", age: 25 }
def birthday($Person p):
p.age = p.age + 1
spawn birthday(bob)
Individual fields cannot be marked shared, share the whole struct instead.
Structs are copied when passed to a spawned function. Use shared only if the thread needs to mutate the same instance the caller holds.