Assign Constructor to Variable Property
After LW Python has finished evaluating the constructor, the return value, which is the reference to the new object, is set to the target in the "Variables" map. 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 = assign statement with target x and expression (Python constructor with name: class_name and arguments: args)
- expression state at time t = "end_expr"
then Variables Map at time (t + 1) = result of storing (Return Value at time t) at key: x in map: (Variables Map at time t)
if the following are true:
- the line at time 52 = 8
- the tab at time 52 = 0
- statement at line 8, tab 0 =
p = Person("John", "Smith", 25)
- expression state at time 52 = "end_expr"
- Variables Map at time 52 = [ ]
- Return Value at time 52 = Python reference 0
then Variables Map at time (52 + 1) = result of storing (Return Value at time 52) at key: p in map: (Variables Map at time 52)
We claim that:
result of storing (Python reference 0) at key: p in map: [ ] = [ entry p: (Python reference 0), [ ] ]
Then we conclude that:
Variables Map at time (52 + 1) = [ entry p: (Python reference 0), [ ] ]
Which simplifies to:
Variables Map at time 53 = [ entry p: (Python reference 0), [ ] ]
See here for the full proof.
Try stepping through the simulator to see LW Python update the "Variable" map with the new object
Current Line | 1 | Current Tab | 0 | Time | 0 |
Comments
Please log in to add comments