Async/Await

Built-in primitives for asynchronous programming and concurrency.

Async Protocol

KEIKAKU Protocol
1async protocol fetch_data(id):
2 declare("Fetching data for", id)
3 sleep(100) # Simulated delay
4 yield "User " + text(id)
5
6# Call implementation
7u := await fetch_data(42)
8declare("Result:", u)

Promises

KEIKAKU Protocol
1# Resolve immediately
2p := resolve("value")
3v := await p
4
5# Create promise from async function
6p_fetch := fetch_data(1)
7# Now execute concurrently...
8another_task()
9# ...and await later
10res := await p_fetch

Defer

Schedule code execution for later without blocking.

KEIKAKU Protocol
1defer(1000, declare, "Executed after 1s")
2declare("This prints first")