All expressions can use function call notation.
Evaluate:
求(方程式,公式,函数)的数值.
Expression can be evaluate differently in different Environment.
Evaluation procedure for call expressions:
- Evaluate the operator and then the operand subexpressions .
- Apply the function that is the value of the operator subexpression to the arguments that are the values of the operand subexpression.
Procedure for calling/applying user-defined functions:
- Add a local frame, titled with the
<name>of the function being called. - Copy the parent of the function to the local frame:
[parent=<label>] - Bind the
<formal parameters>to the arguments in the local frame. - Execute the body of the function in the environment that starts with the local frame.
To evaluate a dot expression:
<expression>. <name>
- Evaluate the
<expression>to the left of the dot, which yields the object of the dot expression. <name>is matched against the instance attributes of that object; if an attribute with that name exists, its value is returned.- If not,
<name>is looked up in the class, which yields a class attribute value. - That value is returned unless it is a function, in which case a bound method is returned instead.