Class Statement Property

When LW Python reads a class statement, it creates a new entry in the "Class Definitions" map where the key is the class name and the value is a list of bases classes (if there are any), methods, and the current line. More formally,

if the following are true:
  • the line at time t = i
  • the tab at time t = j
  • statement at line i, tab j = a class named name with bases: bases

then Class Map at time (t + 1) = result of storing [ entry "bases": bases, [ entry "methods": [ ], [ entry "line": i, [ ] ] ] ] at key: name in map: (Class Map at time t)

For example, if the following are true:

  • the line at time 0 = 1
  • the tab at time 0 = 0
  • statement at line 1, tab 0 = class Person:

then Class Map at time (0 + 1) = result of storing [ entry "bases": [ ], [ entry "methods": [ ], [ entry "line": 1, [ ] ] ] ] at key: "Person" in map: (Class Map at time 0)

Try stepping through the simulator to see LW Python save the class information in the "Class Definitions" map.

Code Editor
LW Python State
Current Line1Current Tab0Time0
LW Python Simulator

Comments

Please log in to add comments