Fundamentals of Computer Science 1 (CS151 2003S)

Symbolic Values in Scheme

Introduction

While your initial exercises in Scheme have been numeric, Scheme is not limited to numerical computation, but can also operate on pure symbols.

Scheme's ancestor, Lisp, was originally developed to aid in experiments in artificial intelligence. At the time, a leading theory suggested that intelligence emphasizes symbolic manipulation. Hence, it is sensible that Lisp and Scheme include symbols as a basic type. Evidence also shows that many programs most appropriately work on abstract symbolic value.

So, what is a symbol? A symbol is simply a word (usually) that we use to denote only itself. Unlike a variable, it has no associated value. Symbols are also atomic, we cannot split them apart (as we might a sequence of letters). The primary operation we perform on symbols is comparison (determining whether two symbols are the same).

Writing Symbols

When we want to refer to something as a value involved in a computation, rather than as the name of some other value, we put an apostrophe (usually pronounced quote) in front of it. In effect, by quoting the symbol, we're telling Scheme to take it literally and without further interpretation or evaluation:

> 'sample
sample

Side Note: Quoting Other Values

Note that quote does not create a symbol. Rather, it tells Scheme to take something literally. Hence, you can can quote many different things. For example, you can even quote Scheme expressions.

> '(+ 2 3)
(+ 2 3)

Although you can use quote in a variety of ways, I prefer that you limit your use to quoting symbolic values, at least for the first few weeks of class. My experience shows that those who quote lists early in the course careers end up with confusing results later in the course.

 

History

Wednesday, 4 September 2002 [Samuel A. Rebelsky]

Tuesday, 21 January 2003 [Samuel A. Rebelsky]

Friday, 24 January 2003 [Samuel A. Rebelsky]

 

Disclaimer: I usually create these pages on the fly, which means that I rarely proofread them and they may contain bad grammar and incorrect details. It also means that I tend to update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This document was generated by Siteweaver on Tue May 6 09:31:13 2003.
The source to the document was last modified on Fri Jan 24 12:07:38 2003.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2003S/Readings/symbols.html.

You may wish to validate this document's HTML ; Valid CSS! ; Check with Bobby

Samuel A. Rebelsky, rebelsky@grinnell.edu