Call Function Values Property

When the state is "call_function_begin" and "Expression" is not a built-in function, then set the function call arguments to the reverse of the first element of the "Values" stack. 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 = function call with name: name and arguments: args

then Argument Values at time (t + 1) = reverse of values

Once the function call arguments have been evaluated, Python passes the arguments into the function. Since the arguments are stored in the "Values" stack in reverse order, LW Python reverses this list to return the arguments to the original order. For example, if the following are true:

  • expression state at time 16 = "call_function_begin"
  • Value Stack at time 16 = [ [ 4, [ 3, [ ] ] ], [ ] ]
  • the expression at time 16 = compare(3, 4)

then Argument Values at time (16 + 1) = reverse of [ 4, [ 3, [ ] ] ]

Try stepping through the simulator to see LW Python set the "Call State Argument Values" to [3,[4,[]]]

Code Editor
LW Python State
Current Line1Current Tab0Time0
LW Python Simulator

Comments

Please log in to add comments

JIYOUNG LEE 1 year ago
test