Chapter 10 - Function implementation. The stack implementation of function call and return is a central topic deserving deeper study. Moreover, strategies for the management of another memory area called the heap, are important to the understanding of dynamic objects like arrays. Chapter 10a presents the following content: Function declaration and call in clite, completing the clite type system, semantics of call and return. | Programming Languages 2nd edition Tucker and Noonan Chapter 10 Function Implementation In theory, there is no difference between theory and practice, but not in practice. Anonymous Contents Function Declaration and Call in Clite Completing the Clite Type System Semantics of Call and Return Formal Treatment of Types and Semantics Function Declaration and Call Example Clite Program Fig int h, i; void B(int w) { int j, k; i = 2*w; w = w+1; } void A(int x, int y) { bool i, j; B(h); } int main() { int a, b; h = 5; a = 3; b = 2; A(a, b); } Concrete Syntax Functions and Globals (new elements underlined) Program { Type Identifier FunctionOrGlobal } MainFunction Type int | boolean | float | char | void FunctionOrGlobal ( Parameters ) { Declarations Statements } | Global Parameters [ Parameter { , Parameter } ] Global { , Identifier } ; MainFunction int main ( ) { Declarations Statements } Concrete Syntax (cont’d) Function Calls (new elements underlined) Statement ; | Block | Assignment | IfStatement | WhileStatement | CallStatement | ReturnStatement CallStatement Call ; ReturnStatement return Expression ; Factor Identifier | Literal | ( Expression ) | Call Call Identifier ( Arguments ) Arguments [ Expression { , Expression } ] Abstract Syntax Program = Declarations globals; Functions functions Functions = Function* Function = Type t; String id; Declarations params, locals; Block body Type = int | boolean | float | char | void Statement = Skip | Block | Assignment | Conditional | Loop | Call | Return Call = String name; Expressions args Expressions = Expression* Return = Variable target; Expression result Expression = Variable | Value | Binary | Unary | Call Abstract Syntax for a Clite Program Fig globals body Program Functions Declarations Function Function Function int main void A void B params locals body h i w A(a,b); a b i j x y w = w + 1; i = 2 * w; j k Block Call Completing the Clite Type . | Programming Languages 2nd edition Tucker and Noonan Chapter 10 Function Implementation In theory, there is no difference between theory and practice, but not in practice. Anonymous Contents Function Declaration and Call in Clite Completing the Clite Type System Semantics of Call and Return Formal Treatment of Types and Semantics Function Declaration and Call Example Clite Program Fig int h, i; void B(int w) { int j, k; i = 2*w; w = w+1; } void A(int x, int y) { bool i, j; B(h); } int main() { int a, b; h = 5; a = 3; b = 2; A(a, b); } Concrete Syntax Functions and Globals (new elements underlined) Program { Type Identifier FunctionOrGlobal } MainFunction Type int | boolean | float | char | void FunctionOrGlobal ( Parameters ) { Declarations Statements } | Global Parameters [ Parameter { , Parameter } ] Global { , Identifier } ; MainFunction int main ( ) { Declarations Statements } Concrete Syntax (cont’d) Function Calls (new elements .