Home / Learn / 6 Functions and their results
Release v0.4.0Edition 0.2
6.8 Recap and reference
Page 9 of 9
6.8.1 For agents
una --json check . gives every diagnostic with its code, message, primary span and repairs. U2004 and U7001 carry exact edits, which una fix . applies. U3004's repair, a uses line, widens authority and is a description with no edit: add it by hand. U5001 carries ranked repairs that need a decision. una contract module.name prints a function's whole header, declared or inferred. The compact rule: label every argument after the first; x.f(args) is f(x, args); a call that prints is a line or a let of its own; a block's last line is the result; a pub header declares its uses; callers rely only on the header.
6.8.2 Recap
- Label every argument after the first; a name equal to its parameter's name counts as its label, and labeled arguments may come in any order.
lamp.rate()israte(lamp): the value before the dot is the first argument. Without parentheses, a field of that name comes first.- Arguments are evaluated left to right, inner calls first; a call that prints is a line or a
letof its own. - A function's result is its body's value: the one line of the short form, or the last line of a block. Una has no
return. - A statement may throw away only a
Unitvalue; bind any other withlet. - A caller knows a result only from the header: its type and its
ensures. - A
pubfunction writes itsuses; a private one may leave them out, anduna contractshows what the checker inferred.
6.8.3 Reference
- Construct pages: functions: forms, clauses, labels, method calls,
ensuresandresult,uses, canonical form - Commands:
una contract,una report,una fmt,una fix - Diagnostics: U0101, U0102, U0103, U2001, U2004, U2005, U2006, U2011, U3001, U3004, U3013, U5001, U6003, U7001
- Specification: functions and contracts, grammar, capabilities and effects, verification, canonical form