Push Method Arguments

When evaluating a method call, the method call arguments are first pushed into the "Arguments" stack. More formally,

if the following are true:
  • expression state at time t = "begin_expr"
  • the expression at time t = obj_name.method_name(args)

then arguments stack at time (t + 1) = [ args, arguments stack at time t ]

For example, if the following are true:

  • expression state at time 54 = "begin_expr"
  • the expression at time 54 = p.age_in_months()
  • arguments stack at time 54 = [ ]

then arguments stack at time (54 + 1) = [ [ ], arguments stack at time 54 ]

In this case, the method call doesn't contain any arguments, so an empty list is pushed into the "Arguments" stack. Try stepping through the simulator to see how LW Python evaluates a method call.

Code Editor
LW Python State
Current Line1Current Tab0Time0
LW Python Simulator

Comments

Please log in to add comments