10.6.1 Symbols
Symbols are much like strings. A symbol is an instance of the built-in class <symbol>. The key difference between strings and symbols lies in the way similarity (as tested by =) and identity (as tested by ==) are defined for each of them. Two string operands can be similar but not identical. However, two symbol operands that are similar are always identical — that is, they always refer to the same object.
There are two reasons to use symbols in certain cases where you might consider using strings. First, symbol comparison is not case sensitive. Second, comparison of two symbols is much faster than is comparison of two strings, because symbols are compared by identity, and strings are usually compared element by element.
In the <directed-angle> class, we define the type of the two slots as <symbol>, instead of <string>, which we used in previous versions of this class. If we use strings, then when we checked whether the direction slot of a latitude was "north" or "south", we would have to worry about uppercase versus lowercase. For example, we would have to decide whether each of these were valid values: "north", "NORTH", "North", "NOrth", and so on. We simplify that decision by using the <symbol> type instead of <string>.
There are two equivalent syntaxes for specifying symbols:
Examples of use of the keyword syntax are:
north:andsouth:.Examples of use of the hash syntax are:
#"north"and#"south".
Here, we show that symbol comparison is not case sensitive:
? #"NORTH" == #"North"; #t
Here, we show that the two syntaxes are equivalent:
? north: == #"norTH"; #t
It is our convention in this book to reserve the keyword syntax for keyword parameters, and otherwise to use the hash syntax. For example, we would give the call:
make(<latitude>, direction: #"north")
instead of the call:
make(<latitude>, direction: north:)




