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() is rate(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 let of 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 Unit value; bind any other with let.
  • A caller knows a result only from the header: its type and its ensures.
  • A pub function writes its uses; a private one may leave them out, and una contract shows what the checker inferred.

6.8.3 Reference

Next:7 Results and failures