2.3 How to Design Programs Teaching Languages🔗

Five of DrRacket’s languages are specifically designed for teaching:

The teaching languages are different from conventional Racket in a number of ways:

The teaching languages also deviate from traditional Racket in printing values. Different printing formats can be selected for any language through the detail section of language-selection dialog.

A program in the teaching languages should be tested using the check forms — (check-expect value value), (check-within value value value), or (check-error value string). Tests are evaluated when running the program: when there are no tests, a warning appears in the interactions window; when all tests succeed, an acknowledgement appears in the interactions window; otherwise, a testing window appears to report the results. See View for details on configuring the report behavior.

Tests can be disabled if necessary, see Racket for details.

One final difference between these teaching languages and other languages is the way they save files. That is, when DrRacket saves a file and the current language is one of these five teaching languages, it inserts three lines of metadata that record the precise language (including any options set) and the teachpacks. This has two benefits: opening the file later restores the settings and the metadata is formulated in such a way as to be executable code so running racket or gracket on the file in a shell will run the program in the appropriate language.

This meta data always consists of exactly three lines, and so can be stripped out by three calls to read-line.