Foreword |
|
xi | |
Preface |
|
xiii | |
Acknowledgments |
|
xix | |
|
1 Flexibility in Nature and in Design |
|
|
1 | (20) |
|
1.1 Architecture of computation |
|
|
5 | (2) |
|
1.2 Smart parts for flexibility |
|
|
7 | (5) |
|
1.3 Redundancy and degeneracy |
|
|
12 | (2) |
|
|
14 | (3) |
|
1.5 The cost of flexibility |
|
|
17 | (4) |
|
2 Domain-Specific Languages |
|
|
21 | (46) |
|
|
22 | (15) |
|
2.1.1 Function combinators |
|
|
23 | (13) |
|
2.1.2 Combinators and body plans |
|
|
36 | (1) |
|
|
37 | (9) |
|
2.2.1 A regular expression combinator language |
|
|
38 | (1) |
|
2.2.2 Implementation of the translator |
|
|
39 | (7) |
|
|
46 | (6) |
|
2.3.1 Specialization wrappers |
|
|
49 | (1) |
|
2.3.2 Implementing specializers |
|
|
50 | (2) |
|
|
52 | (1) |
|
|
52 | (12) |
|
2.4.1 A monolithic implementation |
|
|
53 | (5) |
|
2.4.2 Factoring out the domain |
|
|
58 | (6) |
|
|
64 | (3) |
|
3 Variations on an Arithmetic Theme |
|
|
67 | (90) |
|
3.1 Combining arithmetics |
|
|
67 | (20) |
|
3.1.1 A simple ODE integrator |
|
|
68 | (3) |
|
3.1.2 Modulating arithmetic operators |
|
|
71 | (2) |
|
3.1.3 Combining arithmetics |
|
|
73 | (7) |
|
3.1.4 Arithmetic on functions |
|
|
80 | (3) |
|
3.1.5 Problems with combinators |
|
|
83 | (4) |
|
3.2 Extensible generic procedures |
|
|
87 | (16) |
|
|
90 | (4) |
|
3.2.2 Construction depends on order! |
|
|
94 | (3) |
|
3.2.3 Implementing generic procedures |
|
|
97 | (6) |
|
3.3 Example: Automatic differentiation |
|
|
103 | (22) |
|
3.3.1 How automatic differentiation works |
|
|
105 | (6) |
|
3.3.2 Derivatives of n-ary functions |
|
|
111 | (2) |
|
3.3.3 Some technical details |
|
|
113 | (10) |
|
3.3.4 Literal functions of differential arguments |
|
|
123 | (2) |
|
3.4 Efficient generic procedures |
|
|
125 | (7) |
|
|
125 | (6) |
|
|
131 | (1) |
|
3.5 Efficient user-defined types |
|
|
132 | (22) |
|
3.5.1 Predicates as types |
|
|
133 | (2) |
|
3.5.2 Relationships between predicates |
|
|
135 | (1) |
|
3.5.3 Predicates are dispatch keys |
|
|
136 | (2) |
|
3.5.4 Example: An adventure game |
|
|
138 | (16) |
|
|
154 | (3) |
|
|
157 | (76) |
|
|
158 | (2) |
|
|
160 | (10) |
|
4.2.1 Segment variables in algebra |
|
|
162 | (2) |
|
4.2.2 Implementation of rule systems |
|
|
164 | (2) |
|
4.2.3 Aside: Magic macrology |
|
|
166 | (2) |
|
4.2.4 Pattern-directed invocation |
|
|
168 | (2) |
|
4.3 Design of the matcher |
|
|
170 | (13) |
|
|
176 | (3) |
|
4.3.2 Match-variable restrictions |
|
|
179 | (4) |
|
|
183 | (26) |
|
4.4.1 How unification works |
|
|
185 | (8) |
|
4.4.2 Application: Type inference |
|
|
193 | (3) |
|
4.4.3 How type inference works |
|
|
196 | (7) |
|
4.4.4 Adding segment variables---an experiment! |
|
|
203 | (6) |
|
4.5 Pattern matching on graphs |
|
|
209 | (22) |
|
|
210 | (1) |
|
4.5.2 Implementing graphs |
|
|
211 | (2) |
|
|
213 | (3) |
|
4.5.4 Chessboards and alternate graph views |
|
|
216 | (5) |
|
|
221 | (4) |
|
4.5.6 Implementing graph matching |
|
|
225 | (6) |
|
|
231 | (2) |
|
|
233 | (66) |
|
5.1 Generic eval/apply interpreter |
|
|
234 | (16) |
|
|
235 | (9) |
|
|
244 | (6) |
|
5.2 Procedures with non-strict arguments |
|
|
250 | (9) |
|
5.3 Compiling to execution procedures |
|
|
259 | (10) |
|
|
269 | (11) |
|
|
271 | (2) |
|
|
273 | (7) |
|
5.5 Exposing the underlying continuations |
|
|
280 | (16) |
|
5.5.1 Continuations as nonlocal exits |
|
|
284 | (1) |
|
5.5.2 Nonlocal transfer of control |
|
|
285 | (3) |
|
5.5.3 From continuations to amb |
|
|
288 | (8) |
|
5.6 Power and responsibility |
|
|
296 | (3) |
|
|
299 | (28) |
|
|
300 | (1) |
|
6.2 Implemention of layering |
|
|
301 | (8) |
|
|
302 | (3) |
|
|
305 | (4) |
|
|
309 | (6) |
|
|
310 | (5) |
|
6.4 Annotating values with dependencies |
|
|
315 | (8) |
|
|
317 | (5) |
|
6.4.2 Carrying justifications |
|
|
322 | (1) |
|
6.5 The promise of layering |
|
|
323 | (4) |
|
|
327 | (46) |
|
7.1 An example: Distances to stars |
|
|
329 | (13) |
|
7.2 The propagation mechanism |
|
|
342 | (7) |
|
|
343 | (3) |
|
|
346 | (3) |
|
7.3 Multiple alternative world views |
|
|
349 | (2) |
|
|
351 | (4) |
|
7.4.1 Merging base values |
|
|
351 | (1) |
|
7.4.2 Merging supported values |
|
|
352 | (1) |
|
|
353 | (2) |
|
7.5 Searching possible worlds |
|
|
355 | (14) |
|
7.5.1 Dependency-directed backtracking |
|
|
358 | (6) |
|
7.5.2 Solving combinatorial puzzles |
|
|
364 | (5) |
|
7.6 Propagation enables degeneracy |
|
|
369 | (4) |
|
|
373 | (26) |
|
A Appendix: Supporting Software |
|
|
377 | (2) |
|
|
379 | (20) |
|
|
379 | (15) |
|
|
394 | (5) |
References |
|
399 | (10) |
Index |
|
409 | (16) |
List of Exercises |
|
425 | |