Python §4

Python §4 is a small programming language, designed for the fourth chapter of the textbook Structure and Interpretation of Computer Programs, Python Adaptation (SICPy).

What names are predeclared in Python §4?

On the right, you see all predeclared names of Python §3, in alphabetical order. Click on a name to see how it is defined and used. They come in these groups:

  • MISC: Miscellaneous constants and functions
  • MATH: Mathematical constants and functions
  • LINKED LIST: Support for linked lists
  • PAIR MUTATOR: Mutating pairs
  • LIST: Support for lists
  • STREAM: Support for streams
  • MCE: Support for the meta-circular evaluator

What can you do in Python §4?

You can use all features of Python §3 and the three functions that are introduced in chapter 4 of the textbook, given in MCE.

How can you watch your program run?

In Python §3 and §4, programs have state: an assignment changes a variable or a list, and what a call of a function does depends on the environment in which the function was defined. The playground's E-Stepper tab, the environment stepper, shows how your program runs, one small step at a time. Press Run, then drag the slider, or use the buttons or the keys f (next step) and b (previous step).

In each step, the program is rewritten: the part that is evaluated next, and then its result, are highlighted. The body of a function that is being evaluated is marked with a coloured bracket that names the frame in which it runs (E1, E2, ...), and lists and function objects are shown as small badges (#1, #2, ...) that refer to the objects drawn in the environment diagram next to the program. Read the guide to the environment stepper to learn what the brackets, labels and badges mean.

You want the definitive specs?

For our development team, we are maintaining a definitive description of the language, called the Specification of Python §4. Feel free to take a peek!