---
title: "9.8 Recap and reference"
url: https://una-lang.org/en/learn/loops/recap-and-reference/
release: v0.4.0
edition: "0.2"
---

# 9.8 Recap and reference

## 9.8.1 For agents

:::agents
`una --json check .` prints each diagnostic with its `code`, `message`, `primary` span and `repairs`; U5001 also carries a `counterexample`. U2019 has no repair: its message names the declaration, `let edit x`, or, for a loop variable, which is read-only, a copy bound in the body, `let edit next_x = x`. U5001 and U5002 rank repairs without edits, from a guard (`escape_cost` 0) to `checked` (1). The compact rule: *`for` walks `a..b` (end included), `a..<b` (end left out), `t.chars()` or `t.split(on: s)`, fixed before the first turn; a name a loop changes is `let edit`, declared before it, with a refined type when the code after the loop needs its fact.*
:::

## 9.8.2 Recap

:::recap
- `a..b` includes `b`, `a..<b` leaves it out, and a range whose start is above its end runs no turn.
- Walk a text with `text.chars()` or `text.split(on: s)`, never the text itself.
- The range is fixed before the first turn, and every turn runs: there is no `break` and no `while`.
- Declare an accumulator before its loop with `let edit`, at the value for no turn, and change it by assignment.
- A plain `let` and the loop variable are never assigned, and no name shadows another.
- The verifier checks a body once for any turn, and keeps only the refined types of the names the loop changes.
- Give an accumulator a refined type, `let edit total: Units = 0`, when the code after the loop needs its fact.
- With no limit known in advance, use recursion with a case that stops it.
:::

## 9.8.3 Reference

:::reference
- Construct pages: [`for`](https://una-lang.org/en/docs/language/control-flow/for/), [`let edit`](https://una-lang.org/en/docs/language/control-flow/let-edit/), [refined kinds and `where`](https://una-lang.org/en/docs/language/types/where/), [`requires`](https://una-lang.org/en/docs/language/functions/requires/), [what the verifier proves](https://una-lang.org/en/docs/language/verification/), [`example`](https://una-lang.org/en/docs/language/examples/example/)
- Standard library: [the prelude](https://una-lang.org/en/docs/std/) (`is_digits`, `trim`), [text](https://una-lang.org/en/docs/std/text/) (`chars`, `split`, `slice`)
- Diagnostics: [U0101](https://una-lang.org/en/docs/errors/U0101/), [U0103](https://una-lang.org/en/docs/errors/U0103/), [U1002](https://una-lang.org/en/docs/errors/U1002/), [U2001](https://una-lang.org/en/docs/errors/U2001/), [U2019](https://una-lang.org/en/docs/errors/U2019/), [U5001](https://una-lang.org/en/docs/errors/U5001/), [U5002](https://una-lang.org/en/docs/errors/U5002/)
- Specification: [memory model: editable bindings and loops](https://una-lang.org/en/docs/spec/17-memory-model/), [verification](https://una-lang.org/en/docs/spec/12-verification/), [text](https://una-lang.org/en/docs/spec/22-text/), [standard library](https://una-lang.org/en/docs/spec/14-standard-library/)
:::
