Slide 5 of 74

Names have shapes

type Shape {                  // a declared type, met properly later on
	Circle { radius: Int }
}

proc main(): void {
	name := "bee"             // camelCase: a variable
	MAX_RETRIES := 5          // UPPER_CASE: a variable nothing reassigns
	shape := Shape.Circle(4)  // PascalCase: a type and its variant
	_scratch := 0             // a leading _ is set aside

	echo "{name}, retry up to {MAX_RETRIES} times, radius {_scratch + 4}"
	echo shape                // {4}: a value shows as its fields
}

A name's spelling says what it is, and each shape is enforced where the name is declared:

  • camelCase names variables, parameters, fields, every proc, func and query, and the name an import is reached through.
  • PascalCase names types, their variants, and atoms.
  • UPPER_CASE may name a variable nothing reassigns, the way a constant is usually spelled. It is only ever allowed, never required — camelCase is the default — and a mut variable, a parameter, a field, a loop counter or a name a pattern binds may not use it.

A leading _ is set aside before the shape is checked, so _scratch and _MAX are fine, and _ on its own throws a value away. Names are ASCII letters, digits and _; café is not one.

The keywords are import proc func query test type if else return is with void true false echo assert panic dyn mut async await for in each bounds break continue. They are lower case and only lower case, and they are reserved in every casing: Proc or IF is a compile error naming both readings, and no name anywhere may lowercase to a keyword — a variant called Return, a type called Test or a field called type is refused. A field whose JSON key is a keyword takes another name and says the key in an annotation, shown on the JSON slide.