Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Atoms and Values

The reader is small. Source text is made of parenthesized lists, atoms, comments (; to end of line), and four prefix characters covered in later chapters (', `, ,, ,@). An atom is a maximal run of symbol characters — alphanumerics plus + - * / ? ! < > = _ # . — classified after the fact: the token nil is nil, a token matching -?[0-9]+ is an integer, and anything else is a symbol.

Numbers

Integers are 64-bit and signed. They evaluate to themselves:

42
;=> 42
-7
;=> -7

Booleans are numbers

There is no boolean type. The reader takes #t to the literal 1 and #f to the literal 0, and every predicate in the language answers 1 or 0:

#t
;=> 1
#f
;=> 0
(number? #t)
;=> 1

if (later chapter) treats 0 as false and any other number as true. The practical consequence is that logic is arithmetic — a habit the library code leans on, and one worth acquiring early.

Symbols

A symbol is an interned name. Evaluating one looks it up as a variable, so to get the symbol itself it must be quoted:

'hello
;=> 'hello
'two-words?
;=> 'two-words?

Quotation gets a full treatment in the chapter on pairs and lists; for now, 'x is the datum x, not the value of a variable named x. Note the printer preserves the convention: symbols display with their quote, so what you see can be typed back in.

nil

nil is the empty list, and the terminator of every proper list. It is a distinct value — not a number, not a symbol, and notably not false: if rejects it as a condition. It evaluates to itself:

nil
;=> nil
(null? nil)
;=> 1

The value kinds

Everything a floor program can compute is one of seven kinds of value. Three have appeared already: numbers, symbols, and nil. The rest, with their printed forms, are:

  • Pairs, printed (1 2 3) or (1 . 2) — the chapter on pairs and lists.
  • Closures, printed #<closure> — the chapter on functions.
  • Code, printed #<code N nodes> — a program fragment held as a value, the subject of Part II. N counts expression nodes, since residual programs get too large to print in full.
  • Cells, printed #<cell N> — mutable references, the last chapter of this part.

There are no strings, no characters, and no floats. Symbols do the work strings would do elsewhere; the reference implementations make the same economy.