POLYTONE — the AI-native programming language

Guide

async & tasks

Since Sprint 67, async means something — the smallest true semantics: calling an async fn runs nothing and yields a Task[T]; .run() is the only way anything happens. Deterministic, no scheduler, no await.

scores.pt
import tasks

async fn fetch_score(player: Text) -> Int:
    print("scoring {player}...")
    return player.len() * 10

fn main() -> Void:
    let t = fetch_score("ada")
    print("nothing has run yet")
    print("ada: {t.run()}")
    let scores = tasks.all([
        fetch_score("grace"),
        fetch_score("alan"),
    ])
    print("all: {scores}")

The first line proves the deferral: creating the Task printed nothing. tasks.all — stdlib, written in POLYTONE — drives a list in order and collects the results. And the misuses teach, like everything else here:

dropped.pt
async fn ping() -> Int = 1

fn main() -> Void:
    ping()