Book
Structs
% declares a shape. @ adds members. Methods use . for the receiver.
Primary and extra
% is the primary shape (one per name). @ adds members, often in another file. Members use the same $ / ~ / # leaders as top level.
Receiver
Call u.greet() and inside the method bare . is the receiver. Free functions do not get a receiver.
% user {
$ name
~ visits = 0
$ greet = () {
^ "Hello, {.name}"
}
$ visit = () {
~ .visits = .visits + 1
^ .
}
}
$ u = user {
name: "Ada",
visits: 0
}
u.greet()
u.visit()Sharing and chaining
Struct values are references, so passing a struct or binding it to another name shares one domain object. A plain method that falls off its body returns that receiver. Mutation methods can therefore read naturally as chains without a special builder type.