Expressions, Evaluation and Basic Syntax
3.1 Prefix Notation
(+ 1 2) ; 3
(+ 1 2 3 4) ; 10
(* 2 (+ 3 4)) ; 14
(- 10) ; -10 (unary negation)
(/ 10 4) ; 5/2 (exact rational!)
(max 3 7 2) ; 7
(< 1 2 3) ; #t (chained comparison)3.2 Evaluation Rules
Constants (numbers, strings, characters, booleans) evaluate to themselves.
Variables (symbols) evaluate to their bound values.
Procedure calls (operator operand ...): evaluate the operator and all operands (in an unspecified order), then apply.
Special forms (define, lambda, if, quote, set!, let, cond, ...) and macros follow their own rules.
(define x 10)
(if (> x 5) 'big 'small) ; big: only one branch is evaluated
'(+ 1 2) ; (+ 1 2): quote prevents evaluation3.3 Comments and Lexical Syntax
Identifiers can contain most characters: list->vector, string?, set-car!, *global*, <=?, λ.
Naming conventions: ? for predicates, ! for mutators, -> for conversions, * for variants (let*), and % prefix for internal names.
Case sensitivity: R7RS and R6RS are case-sensitive (R5RS was case-insensitive). Use #!fold-case for case-insensitive code.
; line comment
#| block comment
#| nestable |# |#
#;(this datum is commented out) ; datum comment