imperative / Python
Representation
Collected by Andreas Mühling — Own practice
Expandable 'offline' model of program execution. In its advanced stage (V3) it covers everything of V1 and V2 plus lists and references.
PL | NM |
---|---|
... | ... |
heap | object table of address and value |
reference | addresss used as a value (denoted in <...>) |
object | entry in object table with address and value |
Object types and references.
Introducing references.
Time consuming to prepare. Easy to follow for learners, as it grows in complexity. Can be used for exercises (fill out sheets of the computer).
The idea is to offer an "offline" (in the sense of not automated) visualization of program execution. The necessary model of the computer executing the program gets increasingly more complex, as more programming constructs are introduced. Similar ways of stepping through code can be found in the typical visualization (or debugging) tools and this connection between "offline" and "online" is intentional.
In its basic form, the executor can "run" a script sequentially and jump in the script based on the evaluation of a conditional. Variables of "primitive" types (i.e. str, int, float, bool) are stored in a memory table that consists of identifier and current value. A template for all stages can be found here An example for the execution of a simple script in German can be found here ("Speicher" = "Memory", Bezeichner = Identifier, Wert = Value, Bedingung = Condition, Nächste Zeile = Next Line).
It also shows the big drawback of having it as slides only: It becomes cumbersome for more than very simple scripts to create and once finished, modifications to a program are time consuming. The advantage is that, once introduced, it is not necessary to always step through a program from the beginning, a slide can also jump right into the middle of an execution to highlight interesting phenomena. As it is manual and on slides, it is also easy to add boxes or other elements to guide students' attention to some aspect. Also, the template can be used in exercises and assessments and students can fill in various aspects of the NM (e.g. the memory after a program has been run).
Do you have feedback on this notional machine? Did you find a mistake, or do you have a request for improvement? You can create an Issue on GitHub, where the description is hosted. This way we can see your feedback and address it.
For this, you need a GitHub account. Then follow this link to see the source file of this page. In there, click the ... left of the highlighted line, then pick "Reference in a new issue".