Concepts of Programming Languages
420 Chapter 9 Subprograms int myfun2 (int, int); // A function declaration int (*pfun2)(int, int) = myfun2; // Create a pointer ...
9.8 Overloaded Subprograms 421 Objects of a delegate class can store more than one method. A second method can be added using th ...
422 Chapter 9 Subprograms the actual parameters in a method call, but two or more methods have param- eter profiles that can be ...
9.9 Generic Subprograms 423 Parametric polymorphism is provided by a subprogram that takes generic parameters that are used in t ...
424 Chapter 9 Subprograms Although this process could be defined as a macro, a macro would have the disadvantage of not operatin ...
9.9 Generic Subprograms 425 float flt_list[100]; ... generic_sort(flt_list, 100); The templated functions of C++ are a kind of p ...
426 Chapter 9 Subprograms Now, consider the following version of doIt, which has a bound on its generic parameter: public static ...
9.9 Generic Subprograms 427 9.9.3 Generic Methods in C# 2005 The generic methods of C# 2005 are similar in capability to those o ...
428 Chapter 9 Subprograms Arithmetic operators are examples of type-constrained operations. For exam- ple, consider the followin ...
9.10 Design Issues for Functions 429 can have either pass-by-value or pass-by-reference parameters, thus allowing functions that ...
430 Chapter 9 Subprograms 9.11 User-Defined Overloaded Operators Operators can be overloaded by the user in Ada, C++, Python, an ...
9.12 Closures 431 When subprograms can be nested, in addition to locals and globals, the referencing environment of a subprogram ...
432 Chapter 9 Subprograms The makeAdder function is called twice, once with a parameter of 10 and once with 5. Each of these cal ...
9.13 Coroutines 433 thus have static local variables. Secondary executions of a coroutine often begin at points other than its b ...
434 Chapter 9 Subprograms Suppose program units A and B are coroutines. Figure 9.3 shows two ways an execution sequence involvin ...
Summary 435 SUMMARY Process abstractions are represented in programming languages by subpro- grams. A subprogram definition desc ...
436 Chapter 9 Subprograms Parameters that are multidimensioned arrays pose some issues for the lan- guage designer, because the ...
Review Questions 437 What are the advantages and disadvantages of static local variables? What languages allow subprogram defin ...
438 Chapter 9 Subprograms PROBLEM SET What are arguments for and against a user program building additional definitions for exi ...
Programming Exercises 439 second += second; } void main() { int list[2] = {1, 3}; fun(list[0], list[1]); } For each of the follo ...
«
18
19
20
21
22
23
24
25
26
27
»
Free download pdf