kw actor
Reserved keyword
The list of words: §1.4
Syntax
Actor = "actor" Ident [ "sharded" "by" Ident ":" Type ] "{" { ActorMember } "}" ;Grammar: App. A
Defined in
- 1.4 Keywords — Reserved (cannot be used as names)
- 3.4 Declared types — data — a product type with named fields (§4.2).
- 8.8 Local actors — Messages are processed strictly one at a time, in the order of arrival from each sender.
- 12.5 Sharded actors — The key is declared in the header (sharded by name
Examples
actor Session {
var cart: Cart = Cart.empty()
msg add(item: Item) { cart.push(item) }
msg total() -> Money { cart.sum() }
}
let s = spawn Session() // ActorRef<Session>
s.add(item) -> s.total() -> show(it)@idle(ACCOUNT_IDLE)
actor Account sharded by id: AccountId {
var balance: Money = Money.zero()
@transient var hits: u64 = 0
on activate { log.debug("account {id} up") }
msg deposit(x: Money) { balance += x }
msg balance() -> Money { balance }
}
Account(id).deposit(amount)Related diagnostics
unknown-type, actor-cycle, actor-not-hosted