Dictionary Evaluation Property

After the dictionary entries have been evaluated and stored in the "Values" stack, LW Python creates a new Python dictionary object with the stack values and appends this object to the end of the "Object Store." The "Return Value" is set to the reference, or location, of the new dictionary object in the "Object Store." More formally,

if the following are true:
  • expression state at time t = "call_function_begin"
  • Value Stack at time t = [ values, stack ]
  • the expression at time t = Python dictionary elements

then Return Value at time (t + 1) = Python reference (length of stack (Python Object Store at time t))

The reference value is the length of the "Object Store" because the index of the new dictionary in the "Object Store" is the current length of the dictionary (before the new dictionary is appended).

For example, if the following are true:

  • expression state at time 25 = "call_function_begin"
  • Value Stack at time 25 = [ [ entry "MX": "Mexico", [ entry "ES": "Spain", [ ] ] ], [ ] ]
  • the expression at time 25 = {"ES": "Spain", "MX": "Mexico"}

then Return Value at time (25 + 1) = Python reference (length of stack (Python Object Store at time 25))

Try stepping through the simulator to see the object get added to the "Object Store."

Code Editor
LW Python State
Current Line1Current Tab0Time0
LW Python Simulator

Comments

Please log in to add comments