Evaluation, Quote and the REPL

4.1 Evaluation Rules

Self-evaluating atoms (numbers, strings, booleans) evaluate to themselves.

Symbols evaluate to the value bound to them.

Lists are evaluated as function calls (operator first), except for special forms and macros, which have their own rules.

(define x 10)
x                       ; 10
(+ x 5)                 ; 15
(if (> x 5) 'big 'small)   ; big: `if` is a special form (only one branch is evaluated)

4.2 Quote: Stopping Evaluation

(quote (+ 1 2))         ; (+ 1 2): a list, not a computation
'(+ 1 2)                ; same: ' is shorthand for quote
'x                      ; the symbol x itself
(list '+ 1 2)           ; (+ 1 2): built with list
(eval '(+ 1 2))         ; 3: evaluate data as code (Scheme may need an environment argument)

4.3 Quasiquote: Templates

Clojure uses ` `, ~, and ~@; Common Lisp uses `, ,, and ,@`.

(define n 5)
`(n is ,n)              ; (n is 5): , (unquote) evaluates inside a quasiquote
`(1 ,@(list 2 3) 4)     ; (1 2 3 4): ,@ (unquote-splicing) splices a list

4.4 The REPL

Read text into data structures → Evaluate them → Print the result → Loop.

REPL-driven development means growing a program incrementally inside a running image: redefine functions without restarting, inspect live data, and test as you go.