Essentials of programming languages

Daniel P. Friedman · Choice Reviews Online · 2008

4.4 Type Inference 5 Objects and Classes 5.1 Object-Oriented Programming 5.2 Inheritance 5.3 The Language 5.4 Four implementations 6 Objects and Types 6.1 A Simple Typed Object-Oriented Language 6.2 The Type Checker 6.3 The Translator 7 Continuation-Passing Interpreters 7.1 A Continuation-Passing Interpreter 7.2 Procedural Representation of Continuations 7.3 An Imperative Interpreter 7.4 Exceptions and Control Flow 7.5 Multithreading 7.6 Logic Programming 8 Continuation-Passing Style 8.1 Tail Form 8.2 Converting to Continuation-Passing Style 8.3 Examples of the CPS Transformation 8.4 Implementing the CPS Transformation 8.5 Modeling computational effects A The SLLGEN Parsing System B For Further Reading Bibliography Index OrganizationThe first two chapters provide the foundations for a careful study of programming languages.Chapter 1 emphasizes the connection between inductive data specification and recursive programming and introduces several notions related to the scope of variables.Chapter 2 introduces a data type facility.This leads to a discussion of data abstraction and examples of representational transformations of the sort used in subsequent chapters.Chapter 3 uses these foundations to describe the behavior of programming languages.It introduces interpreters as mechanisms for explaining the run-time behavior of languages and develops an interpreter for a simple, lexically scoped language with first-class procedures, recursion, and assignment to variables.This interpreter is the basis for much of the material in the remainder of the book.The chapter then explores call-by-reference, call-by-need, and call-by-name parameterpassing mechanisms, and culminates with a sketch of an interpreter for an imperative language.Chapter 4 extends the language of chapter 3 with type declarations.First we implement a type checker.Next we show how to use the types to enforce abstraction boundaries.Finally we show how the types in program can be deduced by a unification-based type inference algorithm.Chapter 5 presents the basic concepts of object-oriented languages, centered on classes (but ignoring types, which are deferred to chapter 6).We develop an efficient run-time architecture, which is used as the basis for the material in chapter 6.Chapter 6 combines the ideas of the type checker of chapter 4 with those of the object-oriented language of chapter 5, leading to a conventional typed object-oriented language.This requires introducing new concepts including abstract classes, abstract methods, and casting.Chapter 7 rewrites our basic interpreter in continuation-passing style.The control structure that is needed to run the interpreter thereby shifts from recursion to iteration.This exposes the control mechanisms of the interpreted language, and strengthens one's intuition for control issues in general.It also provides the means for extending the interpreter with exception-handling and multithreading mechanisms.Finally, we use continuation-passing style to present logic programming.Chapter 8 is the companion to the previous chapter.There we show how to transform our familiar interpreter into continuation-passing style; here we show how to accomplish this for a much larger class of programs.Continuation-passing style is a powerful programming tool, for it allows any sequential control mechanism to be implemented in almost any language.The algorithm is also a fine example of an abstractly specified source-to-source program transformation.The dependencies of the various chapters are shown in the figure below.Finally, appendix A describes our SLLGEN parsing system. UsageThis material has been used in both undergraduate and graduate courses.In addition, it has been used in continuing education courses for professional programmers.We assume background in data structures and experience both in a procedural language such as C, C++, or Java, and in Scheme.Exercises are a vital part of the text and are scattered throughout.They range in difficulty from being trivial if related material is understood [ ], to requiring many hours of thought and programming work [ ].A great deal of material of applied, historical, and theoretical interest resides within them.We recommend that each exercise be read and some thought be given as to how to solve it.Although we write our program interpretation and transformation systems in Scheme, any language that supports both first-class procedures and assignment (ML, Common Lisp, etc.) is adequate for working the exercises.We are indebted to countless colleagues and students who used and critiqued the first edition of this book and provided invaluable assistance in the long gestation of this second edition.We are especially grateful for the contributions of the following individuals, to whom we offer a special word of thanks.Matthias Felleisen's keen analysis has improved the design of several chapters.Among these, his work with Amr Sabry on the CPS algorithm led to a far more elegant algorithm than we had in the earlier edition.Amr Sabry made many useful suggestions and found at least one extremely subtle bug in a draft of chapter 6. Benjamin Pierce offered a number of insightful observations after teaching from the first edition, almost all of which we have incorporated into the second edition.Gary Leavens provided exceptionally thorough and valuable comments on early drafts of this edition, including a large number of detailed suggestions for change.Jonathan Rossie suggested a subtle refinement of the CPS algorithm, which resulted in a simpler algorithmic structure and more compact output.Olivier Danvy helped in the development of a particularly interesting exercise in chapter 8. Anurag Mendhekar and Michael Levin contributed to the material on logic programming.Ryan Newton, in addition to reading a draft, assumed the onerous task of suggesting a difficulty level for each exercise.

Read the paper · More papers on PaperTik