# Class 12: Scheme Syntax

Back to The Scheme Report. On to Scheme Semantics (1).

Held: Friday, February 17, 2006

Summary: Today we consider issues pertaining to the formal syntax of Scheme.

Related Pages:

Assignments

• Read Section 7.2 of R5RS up to the second equation of the second column of p. 41. Also read the definitions (on the subsequent) of any utility procedures used in those first few equations..

Due

• Homework 1: Implement Lisp.

Notes:

• Because the Scheme semantics is quite involved, there are no programming assignments for the next week. Be prepared to spend two hours per reading.

Overview:

• Quasiquotation.
• Other Syntax Questions.
• Preparing to Read the Semantics.

## Quasiquotation

• As the report suggests, quasiquotation is a notation for building list-like structures in which some, but not all, of the structure is fixed.
• It is much like quotation, except that parts of the quoted expression are to be evaluated.
• A quasiquoted structure begins with a backquote.
• Most of the stuff within a quasiquoted structure is interpreted as if its in a quoted structure.
• Anything that begins with a comma (more or less) is evaluated.
• Anything that begins with a comma and an at sign (more or less) is evaluated as a list, and all elements of the list are inserted at that point.
• For example, I might make an association list of grades as follows
```(define grades
(lambda (jack jane joe jean)
`((jack ,jack) (jane ,jane) (joe ,joe) (jean ,jean))))
```
• The complicating issue in quasiquotations (and their syntax) is that you can nest quasiquotations. In that case, you need the appropriate number of nested commas to evaluate.

## Other Syntax Questions

These are generally gathered from your comments. I will ask you folks for responses, and then insert my own.

• In the expression <number> -> <num 2> | <num 8> | <num 10> | <num 16>, what is the significance of the integers 2,8,10 and 16? I know that binary, octal, hexidecimal and decimal numerical notation is conventional, but why not have 4 or 32?
• Why did the designers include a number of the built-in procedure names such as `set!`?
• One thing I noticed is that it had real, unsigned real, and unsigned int, but there was no signed int. Is there a reason for this?
• If sequence is just 0 or more instances of command followed by an expression, and command is just an expression, why isn't sequence just defined by expression*? Or command*?
• Does <statement>* just imply that the statements are the same, since <statement> could imply any of many different things?
• Why are there #'s in the numbers rules?

• Variable names are intended to give types.
• For example, lowercase alphas are always locations.
• Typography gives context.
• Roman words: Syntactic sets (constants, identifiers, expressions, commands)
• Capital greek letters: Members of those sets
• Monospace capital letters: Types used in the semantics
• Lowercase greek letters: Members of those types
• Script capitals (K, E, E*, and C): The meaning function (essentially, eval for different contexts).

Back to The Scheme Report. On to Scheme Semantics (1).

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 Wed May 10 09:02:49 2006.
The source to the document was last modified on Thu Jan 12 09:00:37 2006.
This document may be found at `http://www.cs.grinnell.edu/~rebelsky/Courses/CS302/2006S/Outlines/outline.12.html`.

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

Samuel A. Rebelsky, rebelsky@grinnell.edu