Quotation Strings - SICP Comparison Edition" /> 2.3.1   <span style="color:green">Quotation</span> <span style="color:blue">Strings</span> - SICP Comparison Edition
Original JavaScript

 Allowing quotation in a language wreaks havoc with the ability to reason about the language in simple terms, because it destroys the notion that equals can be substituted for equals. For example, three is one plus two, but the word three is not the phrase one plus two. Quotation is powerful because it gives us a way to build expressions that manipulate other expressions (as we will see when we write an interpreter in chapter 4). But allowing statements in a language that talk about other statements in that language makes it very difficult to maintain any coherent principle of what equals can be substituted for equals should mean. For example, if we know that the evening star is the morning star, then from the statement the evening star is Venus we can deduce the morning star is Venus. However, given that John knows that the evening star is Venus we cannot infer that John knows that the morning star is Venus.
 The single quote is different from the double quote we have been using to enclose character strings to be printed. Whereas the single quote can be used to denote lists or symbols, the double quote is used only with character strings. In this book, the only use for character strings is as items to be printed.
 Strictly, our use of the quotation mark violates the general rule that all compound expressions in our language should be delimited by parentheses and look like lists. We can recover this consistency by introducing a special form quote, which serves the same purpose as the quotation mark. Thus, we would type (quote a) instead of 'a, and we would type (quote (a b c)) instead of '(a b c). This is precisely how the interpreter works. The quotation mark is just a single-character abbreviation for wrapping the next complete expression with quote to form (quote expression). This is important because it maintains the principle that any expression seen by the interpreter can be manipulated as a data object. For instance, we could construct the expression (car '(a b c)), which is the same as (car (quote (a b c))), by evaluating (list 'car (list 'quote '(a b c))).
 We can consider two symbols to be the same if they consist of the same characters in the same order. Such a definition skirts a deep issue that we are not yet ready to address: the meaning of sameness in a programming language. We will return to this in chapter 3 (section 3.1.3).
 In practice, programmers use equal? to compare lists that contain numbers as well as symbols. Numbers are not considered to be symbols. The question of whether two numerically equal numbers (as tested by =) are also eq? is highly implementation-dependent. A better definition of equal? (such as the one that comes as a primitive in Scheme) would also stipulate that if a and b are both numbers, then a and b are equal? if they are numerically equal.
 We can consider two strings to be the same if they consist of the same characters in the same order. Such a definition skirts a deep issue that we are not yet ready to address: the meaning of sameness in a programming language. We will return to this in chapter 3 (section 3.1.3).
2.3.1   Quotation Strings