POLYTONE — the AI-native programming language

Guide

Record update — with

One canonical form for 'the same record, some fields changed' — no rebuilding every field by hand.

update.pt
record Track:
    title: Text
    plays: Int

fn promote(t: Track) -> Track:
    return t with plays: t.plays + 1

fn main() -> Void:
    let track = Track(title: "arrival", plays: 41)
    let single = promote(track) with title: "arrival (single)"
    print("{track}")
    print("{single}")

Since Sprint 31. Unknown fields list the record's fields, duplicates are errors, and every field expression sees the original subject — p with x: p.y, y: p.x swaps cleanly. One with clause per expression; chaining is a teaching error. The original keeps its value, and the VM's move analysis makes rebuild chains like img = images.set_pixel(img, …) run with zero buffer copies.