Programming Language Pragmatics, Fourth Edition
Format: PDF / Kindle (mobi) / ePub
Programming Language Pragmatics, Fourth Edition, is the most comprehensive programming language textbook available today. It is distinguished and acclaimed for its integrated treatment of language design and implementation, with an emphasis on the fundamental tradeoffs that continue to drive software development.
The book provides readers with a solid foundation in the syntax, semantics, and pragmatics of the full range of programming languages, from traditional languages like C to the latest in functional, scripting, and object-oriented programming. This fourth edition has been heavily revised throughout, with expanded coverage of type systems and functional programming, a unified treatment of polymorphism, highlights of the newest language standards, and examples featuring the ARM and x86 64-bit architectures.
- Updated coverage of the latest developments in programming language design, including C & C++11, Java 8, C# 5, Scala, Go, Swift, Python 3, and HTML 5
- Updated treatment of functional programming, with extensive coverage of OCaml
- New chapters devoted to type systems and composite types
- Unified and updated treatment of polymorphism in all its forms
- New examples featuring the ARM and x86 64-bit architectures
Michael Scott is a talented researcher who has made major contributions in language implementation, run-time systems, and computer architecture. He is exceptionally well qualified to draw on all of these fields ix x Foreword to provide a coherent understanding of modern programming languages. This book not only explains language concepts and implementation details with admirable clarity, but also shows how computer architecture and compilers influence language design and implementation.
Unix’s lex/flex tool produces C language output containing tables and a customized driver. Some other scanner generators produce tables for use with a handwritten driver, which can be written in any language. The nested case statement style of automaton is illustrated in Figure 2.11. The outer case statement covers the states of the finite automaton. The inner case statements cover the transitions out of each state. Most of the inner clauses simply set a new state. Some return from the scanner
will consider this use in Section 9.2.2. 120 Chapter 3 Names, Scopes, and Bindings Figure 3.5 Static chains. Subroutines A , B , C , D , and E are nested as shown on the left. If the sequence of nested calls at run time is A , E , B , D , and C , then the static links in the stack will look as shown on the right. The code for subroutine C can find local objects at known offsets from the frame pointer. It can find local objects of the surrounding scope, B , by dereferencing its static chain
nested subroutines to be passed as parameters, but only outermost routines to be returned or stored in variables (outermost routines are first-class values; nested routines are second-class values). Ada 95 allows a nested routine to be returned, but only if the scope in which it was declared is at least as wide as that of the declared return type. This containment rule, while more conservative than strictly necessary (it forbids the Ada equivalent of Figure 3.13), makes it impossi- D E S I G N &
preconditions, and postconditions are essentially structured assertions. A postcondition, specified once in the header of a Euclid subroutine, will be checked not only at the end of the subroutine’s text, but at every return statement as well, automatically. Many languages support assertions via standard library routines or macros. In C, for example, one can write assert(denominator != 0); If the assertion fails, the program will terminate abruptly with the message myprog.c:42: failed assertion