-
Notifications
You must be signed in to change notification settings - Fork 3
Environment Diagrams
After running a program, we can press "Environments" in the editor to open an environment diagram visualizer. Each frame of the current environment is represented as a rectangle on a draggable canvas. The active frame is highlighted with a solid border, while other frames have dashed borders. By default, each frame has its call stack directly above it, and have a parent of Global unless otherwise specified.
The environment diagram toolbar has a number of buttons - from left to right, they are:
- Step backward. Go back to the most recent variable assignment strictly before the current time, if one exists. Otherwise do nothing.
- Step forward. Go forward to the next variable assignment strictly after the current time, if one exists. Otherwise do nothing.
- Step backward to the time when the first variable was assigned in the current frame.
- Step forward to the time when the last variable is assigned in the current frame.
- Step back to the first variable assignment in the current execution trace.
- Step forward to the last variable assignment in the current execution trace.
- Toggle visualization modes.
Environment diagrams can be displayed in two modes: inline, and box-and-pointer. A new environment diagram defaults to inline mode, but the toggle button in the toolbar can be used to switch between the two modes.
The inline mode displays a string representation of each object adjacent to its binding in its frame. This way is similar to how most real debuggers work, due to its additional clarity in reading long lists. However, it is different from how most environment diagrams are drawn in CS 61A. In addition, the inline mode does not display the forced value of Promise
s, unlike the box-and-pointer mode.
The box-and-pointer mode replicates the behavior of Python Tutor and <scheme.cs61a.org>, and draws objects on the heap using standard box and pointer notation. It can be zoomed and scrolled using the mouse for better clarity. Unlike Python Tutor, however, objects drawn on the heap may move around slightly as we step through programs, which may be a slight source of confusion.
By default, frames are hidden after they return. However, an option in the "Settings" menu (on the global header) will preserve frames even after they return. Setting this option to false will produce the expected behavior in most, but not all cases. In particular, modifications to a Frame after it returns will not necessarily be displayed as expected. This behavior can only occur when using set!
, set-car!
, set-cdr!
, or a (define ...)
statement within a Promise
. Since these aspects of Scheme are not emphasized in the course, in most cases it should be safe to preserve frames after their return.