Go to the first, previous, next, last section, table of contents.

Some Other Useful Data Types

[ Parts of this should probably be moved into the previous chapter, and new examples put in this section. ]

Scheme has several important kinds of data objects that are useful in programming in general, and particularly for writing an interpreter, as we'll do in the next chapter. These include character strings, symbols, and lists.

Scheme has two data types that represent sequences of characters, called strings and symbols. Strings are pretty much like character strings in most programming languages--they represent a sequence of text characters. Symbols are sort of like strings, but have a very special property--there's only one symbol object with any particular sequence of characters.

Symbols have a special role in the implementation of Scheme, because they're part of the normal representation of source code; symbols are used to represent names of variables, procedures, special forms, and macros. They're really just a kind of data object, though--you can use them in your programs, whether or not you want to represent code.

Lists are used in interpreters and compilers to represent compound expressions in the source code; nested expressions are generally represented by nested lists.

More generally, there's a category of Scheme data structures called s-expressions, which consist of basic types including symbols, strings, numbers, booleans, and characters, and list of those simple types, or lists of such lists.

"S-expression" is short for "symbolic expression," but it's something of a misnomer. An expression is really a piece of a program. An "s-expression " is just a data structure, which may or may not represent an expression in a programming language, although interpreters and compilers often happen to use them that way.


Go to the first, previous, next, last section, table of contents.