Lake

Types

§Primitive types

TypeDescription
i6464-bit signed integer
strstring — fat pointer (start, end)
pidprocess identifier — fat pointer to a process context

All values are 64-bit at the machine level. Strings are stored as read-only data with a fat pointer; process ids are heap pointers that remain stable for the lifetime of the process.

§Where types appear

In a typed parameter:

lake
n i64
buf str
target pid

In a literal guard:

lake
0 i64
"hello" str

The literal guard requires the type alongside the literal — types disambiguate dispatch when several branches share the same arity.

§Type-based dispatch

When a machine is called, the compiler hashes the types of the arguments to pick a branch. Within a single type signature, literal guards are then checked in declaration order.

lake
counter is {
  0 i64 -> { ... }   # picked when arg is the i64 literal 0
  n i64 -> { ... }   # picked for any other i64
}

A call counter(5) matches the second branch. A call counter(0) matches the first.

The hash of types is computed at compile time, so dispatch is O(1) at runtime regardless of how many branches a machine has.

§Process identifiers (pid)

A pid is a handle to a spawned process. When a machine is called, it returns a pid you can store, pass around, and send messages to.

lake
let p pid = receiver()
p(42)                   # sends the message 42 to receiver

A pid is a stable heap pointer; it identifies the process for its entire lifetime. See State transitions for spawn/send semantics, and Expressions for the receiving side (wait).