Home / Learn / 16 Memory

Release v0.4.0Edition 0.2

16.9 Recap and reference

Page 10 of 10

16.9.1 For agents

una --json check . gives each diagnostic of this chapter with its code and exact place. For Leaving out edit at the call:

json
{"schema":"una.diagnostics/1","diagnostics":[{"schema":"una.diagnostic/1","code":"U2020","severity":"error","domain":"types","message":"parameter `ledger` of `apply` is declared `edit`, so its argument is written `edit ledger`","primary":{"file":"src/stockcount.una","start":{"line":63,"col":22},"end":{"line":63,"col":28}},"related":[],"repairs":[{"rank":1,"escape_cost":0,"description":"write `edit ledger`","edit":{"file":"src/stockcount.una","start":{"line":63,"col":22},"end":{"line":63,"col":28},"replacement":"edit ledger"}}],"explain":"una explain U2020"}],"fixable":1}

The repair carries an edit that una fix . applies, so the document reports "fixable":1. U2012, U2017, U2019 and U3013 carry no edit: the right change depends on intent. una --json run . reports U6003 with "status":"aborted", as in section 16.4. The compact rule: a call that changes a binding names it with edit, on a line of its own; a binding given with take is not used again until it is assigned; old(x) appears only in ensures, on an edit parameter.

16.9.2 Recap

  • A let binding is a value, and a copy is a value of its own.
  • let edit makes a binding editable: assign it or its fields with =, and a list element with edit xs.set(…).
  • An edit parameter passes a value in and out. The call writes edit, and a failed call leaves the argument unchanged.
  • old(x) is an edit parameter's value on entry, and only ensures may use it.
  • After take x, x is not used again until it is assigned.
  • A loop's turns are not calls: only calls in progress count toward the call depth.
  • U6003 stops a run at the call depth or the memory budget. Build long lists with loops.

16.9.3 Reference

Next:17 Information flow