Slide 7 of 74

Scalar types

proc main(): void {
	Str   name   = "bee"
	Int   count  = 42
	Float weight = 3.14
	Bool  ready  = true
	Atom  state  = #Ready

	echo "{name} {count} {weight} {ready}"
	echo state             // Ready — echo prints an atom's name
	echo "state: {state}"  // state: 1 — inside a string it is its number
	echo state == #Ready   // true — which is why atoms are compared, not printed
}
  • Str holds UTF-8 text.
  • Int is a 64-bit signed integer. It never wraps round: arithmetic that would pass its largest or smallest value stays at that value.
  • Float is a 64-bit floating-point number.
  • Bool is true or false.
  • Atom is a symbol, written #Name.
  • void is a return type only; there is no void value, field or element.

Number literals are decimal and nothing else: no hex, no _ between digits, no exponent. A Float has digits on both sides of its point — 0.5, not .5 or 1. — and -1 is the minus operator applied to 1. No number is ever converted for you: an Int does not become a Float on its own, and hive.conv.itf is how you widen one on purpose.

An atom is a label. echo prints its name, but inside a string — interpolated, or added with + — it becomes the small number the compiler gave it, so compare atoms with == rather than as text. #Nil is always 0; every other atom is numbered by where it is first mentioned, which is also the order sort puts atoms in. An atom cannot be computed, and it is not a condition: if state is a compile error when state is an Atom.