Unlike XML, programming languages let you do more than just structure things. A programming language gives expressions meanings and interpretations. Often, the meaning of an expression is a computation. For example, in a language with arithmetic operators, the interpretation of 7 + 2 is 9. Misp doesn’t have arithmetic operators, it only has symbols and pairs. Misp gives nine symbols special meanings. Today, we will consider the first of these symbols: quote.
Quoting an expression makes it so that we treat the expression as a literal. Let’s look at the example (quote hello). This expression contains two pairs and three symbols. See them? Try looking at the expression without any abbreviations (quote . (hello . nil)). A Misp interpreter determines the meaning of pair by looking at its head. In our example, the head is quote. When Misp sees quote, it knows it should interpret the expression literally. To find the literal component, it looks for the head of the second pair in the list: hello in our example. Thus, the interpretation of (quote hello) is the symbol hello.
Since quote is so useful in Lisps, it has a special shorthand. You can drop the outermost parenthesis and write a single quotation mark at the front. We can reduce (quote hello) to ‘hello. The meaning of ‘hello is hello. Similarly, the meaning of ‘(hello nurse) is (hello nurse). What’s the shorthand for (quote (quote quote)) and what’s it’s meaning? The shorthand is ’’quote. It’s meaning is ‘quote. Using the shorthand notation for quotes makes determining their meaning easy: just drop the quote at the front.
Commentary