Next: , Previous: , Up: scheme overview   [Index]


3.1.12 Syntactic data and datum values

A subset of the Scheme objects is called datum values. These include booleans, number objects, characters, symbols, and strings as well as lists and vectors whose elements are data. Each datum value may be represented in textual form as a syntactic datum, which can be written out and read back in without loss of information. A datum value may be represented by several different syntactic data. Moreover, each datum value can be trivially translated to a literal expression in a program by prepending a ‘'’ (single quote) to a corresponding syntactic datum:

'23             ⇒ 23
'#t             ⇒ #t
'foo            ⇒ foo
'(1 2 3)        ⇒ (1 2 3)
'#(1 2 3)       ⇒ #(1 2 3)

The ‘'’ shown in the previous examples is not needed for representations of number objects or booleans. The syntactic datum ‘foo’ represents a symbol with name “foo”, and ‘'foo’ is a literal expression with that symbol as its value. ‘(1 2 3)’ is a syntactic datum that represents a list with elements ‘1’, ‘2’, and ‘3’, and ‘'(1 2 3)’ is a literal expression with this list as its value. Likewise, ‘#(1 2 3)’ is a syntactic datum that represents a vector with elements ‘1’, ‘2’ and ‘3’, and ‘'#(1 2 3)’ is the corresponding literal.

The syntactic data are a superset of the Scheme forms. Thus, data can be used to represent Scheme forms as data objects. In particular, symbols can be used to represent identifiers.

'(+ 23 42)                 ⇒ (+ 23 42)
'(define (f x) (+ x 42))   ⇒ (define (f x) (+ x 42))

This facilitates writing programs that operate on Scheme source code, in particular interpreters and program transformers.


Next: , Previous: , Up: scheme overview   [Index]