Multistage Algorithms in C++
Total Page:16
File Type:pdf, Size:1020Kb
Multistage Algorithms in C++ Dissertation zur Erlangung des Doktorgrades der Mathematisch-Naturwissenschaftlichen FakultÄaten der Georg-August-UniversitÄat zu GÄottingen vorgelegt von Andreas Priesnitz aus GÄottingen GÄottingen 2005 D7 Referent: Prof. Dr. G. Lube Korreferent: Prof. Dr. R. Schaback Tag der mundlicÄ hen Prufung:Ä 2. November 2005 Andreas Priesnitz Multistage Algorithms in C++ in commemoration of my father, Kuno Priesnitz Contents 1 Frequently Asked Questions 1 1.1 Who is it for? . 1 1.1.1 Domain of interest . 1 1.1.2 Domain of knowledge . 2 1.2 What is it for? . 2 1.2.1 E±ciency . 2 1.2.2 Abstraction . 3 1.2.3 Situation . 4 1.2.4 Quest . 5 1.3 Where is it from? . 5 1.3.1 Related subjects . 6 1.3.2 Related information . 6 1.3.3 Related software . 6 1.4 How is it done? . 7 1.4.1 Structure . 7 1.4.2 Language . 7 1.4.3 Layout . 8 I Paradigms 9 2 Object-oriented programming 11 2.1 User-de¯ned types . 11 2.1.1 Enumeration types . 11 2.1.2 Class types . 12 2.1.3 Class object initialization . 13 2.1.4 Class interface . 14 2.1.5 Global functions . 14 2.1.6 Inheritance . 15 2.1.7 Performance impact . 18 2.2 Dynamic polymorphism . 19 2.2.1 Virtual functions . 19 2.2.2 Integration into the type system . 20 2.2.3 Performance impact . 22 I 3 Generic programming 25 3.1 Class templates . 25 3.1.1 Constant template parameters . 26 3.1.2 Specialization . 26 3.2 Static polymorphism . 28 3.2.1 Function templates . 28 3.2.2 Function template specialization . 28 3.2.3 Concepts . 29 3.2.4 Integration into the type system . 32 3.2.5 Performance impact . 33 4 Meta programming 35 4.1 Meta control structures . 35 4.2 Meta functions . 37 4.2.1 Type arguments . 37 4.2.2 Integral value arguments . 38 4.2.3 Other arguments . 39 4.2.4 Meta vs. soma syntax . 39 4.3 Meta data structures . 39 4.3.1 Integral values . 40 4.3.2 Real values . 41 4.3.3 Stacks . 42 4.3.4 Other structures . 43 5 Functional programming 45 5.1 Meta and functional programming . 45 5.2 Delayed evaluation . 45 5.2.1 Partial binding and partial evaluation . 46 5.2.2 Formal parameters . 46 5.2.3 Lambda expressions . 46 5.2.4 Currying . 47 5.2.5 Positional parameters . 47 II Techniques 49 6 Types 51 6.1 Categories . 51 6.1.1 Builtin types . 51 6.1.2 User-de¯ned types . 53 6.1.3 Internal types . 53 6.2 Traits . 55 6.2.1 Convertibility test . 57 6.2.2 Properties . 58 6.2.3 Specialization by type category . 58 6.2.4 Dispatch by type category . 60 II 7 Mappings 65 7.1 Functions . 66 7.1.1 Plain functions . 66 7.1.2 Generic functions . 67 7.2 Funs . 69 7.2.1 Result type information . 70 7.2.2 Constrained genericity . 71 7.2.3 Multistage functions . 72 7.2.4 Void arguments . 73 7.2.5 Meta expressions . 74 7.2.6 Speci¯cation . 75 7.3 Maps . 76 7.3.1 Speci¯cation . 76 7.3.2 Fun embedding . 76 7.4 Binding . 77 7.4.1 Generalization . 78 7.4.2 Anonymous binding . 78 7.4.3 Analyzation . 79 8 Naming 83 8.1 Identi¯ers . 83 8.1.1 Classi¯cation . 83 8.1.2 Operators . 84 8.2 De¯nitions . 87 8.2.1 Funs . 87 8.2.2 Calls . 87 8.2.3 Global functions . 89 8.2.4 Anonymous function call . 93 III Applications 97 9 Evaluation 99 9.1 Default evaluation . 99 9.2 Immediate evaluation . 100 9.2.1 Object construction . 100 9.2.2 Undelaying objects . 102 9.2.3 Delaying an object . 103 9.3 Delayed evaluation . 104 9.3.1 Presence of actual arguments . 104 9.3.2 Absence of actual arguments . 105 9.4 Non-parallel evaluation . 107 9.4.1 Sequential evaluation . 108 9.4.2 Conditional evaluation . 109 III 10 Semantics 115 10.1 General semantics ..