Build Constructor Arguments Property
LW Python begins creating new variables by creating an entry where the key is "self" and the value is the length of the "Object Store. More formally,"
if the following are true:
- expression state at time t = "call_build_args"
- the expression at time t = Python constructor with name: class_name and arguments: args
- Function Variables Map at time t = [ ]
- Parameters List at time t = [ self, p_rest ]
then Function Variables Map at time (t + 1) = [ entry self: (Python reference (length of stack (Python Object Store at time t))), [ ] ]
For example,
if the following are true:
- expression state at time 21 = "call_build_args"
- the expression at time 21 =
Person("John", "Smith", 25)
- Function Variables Map at time 21 = [ ]
- Parameters List at time 21 = [ self, [ first_name, [ last_name, [ age, [ ] ] ] ] ]
then Function Variables Map at time (21 + 1) = [ entry self: (Python reference (length of stack (Python Object Store at time 21))), [ ] ]
Try stepping through the simulator to see LW Python add "self":0 to the "Function Variables" map.
Code Editor
LW Python State
Current Line | 1 | Current Tab | 0 | Time | 0 |
LW Python Simulator
Comments
Please log in to add comments