solution manual for concepts in programming languages 8.doc_第1页
solution manual for concepts in programming languages 8.doc_第2页
solution manual for concepts in programming languages 8.doc_第3页
solution manual for concepts in programming languages 8.doc_第4页
solution manual for concepts in programming languages 8.doc_第5页
免费预览已结束,剩余46页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Instructors Solutions ManualtoConcepts of Programming LanguagesEighth EditionR.W. SebestaPrefaceChanges to the Eighth EditionThe goals, overall structure, and approach of this eighth edition of Concepts of Programming Languages remain the same as those of the seven earlier editions. The principal goals are to introduce the main constructs of contemporary programming languages and to provide the reader with the tools necessary for the critical evaluation of existing and future programming languages. An additional goal is to prepare the reader for the study of compiler design, by providing an in-depth discussion of programming language structures, presenting a formal method of describing syntax, and introducing approaches to lexical and syntatic analysis. The eighth edition evolved from the seven through two basic kinds of changes. First, to maintain the currency of the material, some of the discussion of older programming languages has been replaced by material on newer languages. Discussions of the unique control structures of Python and Ruby were added to Chapter 8. Ruby blocks and iterators are now covered in Chapter 9. Support for abstract data types in Python and Ruby is discussed in Chapter 11, along with support for generic classes in Java 5.0 and C# 2005. An overview of Ruby support for object-oriented programming has been added to Chapter 12. The second kind of changes are minor changes, primarily to improve clarity, which were made to a large number of sections of the book.The VisionThis book describes the fundamental concepts of programming languages by discussing the design issues of the various language constructs, examining the design choices for these constructs in some of the most common languages, and critically comparing design alternatives.Any serious study of programming languages requires an examination of some related topics, among which are formal methods of describing the syntax and semantics of programming languages, which are covered in Chapter 3. Also, implementation techniques for various language constructs must be considered: Lexical and syntax analysis are discussed in Chapter 4, and implementation of subprogram linkage is covered in Chapter 10. Implementation of some other language constructs is discussed in various other parts of the book.The following paragraphs outline the contents of the seventh edition.Chapter OutlinesChapter 1 begins with a rationale for studying programming languages. It then discusses the criteria used for evaluating programming languages and language constructs. The primary influences on language design, common design tradeoffs, and the basic approaches to implementation are also examined.Chapter 2 outlines the evolution of most of the important languages discussed in this book. Although no language is described completely, the origins, purposes, and contributions of each are discussed. This historical overview is valuable, because it provides the background necessary to understanding the practical and theoretical basis for contemporary language design. It also motivates further study of language design and evaluation. In addition, because none of the remainder of the book depends on Chapter 2, it can be read on its own, independent of the other chapters.Chapter 3 describes the primary formal method for describing the syntax of programming languageBNF. This is followed by a description of attribute grammars, which describe both the syntax and static semantics of languages. The difficult task of semantic description is then explored, including brief introductions to the three most common methods: operational, axiomatic, and denotational semantics.Chapter 4 introduces lexical and syntax analysis. This chapter is targeted to those colleges that no longer require a compiler design course in their curricula. Like Chapter 2, this chapter stands alone and can be read independently of the rest of the book.Chapters 5 through 14 describe in detail the design issues for the primary constructs of the imperative languages. In each case, the design choices for several example languages are presented and evaluated. Specifically, Chapter 5 covers the many characteristics of variables, Chapter 6 covers data types, and Chapter 7 explains expressions and assignment statements. Chapter 8 describes control statements, and Chapters 9 and 10 discuss subprograms and their implementation. Chapter 11 examines data abstraction facilities. Chapter 12 provides an in-depth discussion of language features that support object-oriented programming (inheritance and dynamic method binding), Chapter 13 discusses concurrent program units, and Chapter 14 is about exception handling and event handling.The last two chapters (15 and 16) describe two of the most important alternative programming paradigms: functional programming and logic programming. Chapter 15 presents an introduction to Scheme, including descriptions of some of its primitive functions, special forms, and functional forms, as well as some examples of simple functions written in Scheme. Brief introductions to ML and Haskell are given to illustrate some different kinds of functional language. Chapter 16 introduces logic programming and the logic programming language, Prolog.To the InstructorIn the junior-level programming language course at the University of Colorado at Colorado Springs, the book is used as follows: We typically cover Chapters 1 and 3 in detail, and though students find it interesting and beneficial reading, Chapter 2 receives little lecture time due to its lack of hard technical content. Because no material in subsequent chapters depends on Chapter 2, as noted earlier, it can be skipped entirely, and because we require a course in compiler design, Chapter 4 is not covered.Chapters 5 through 9 should be relatively easy for students with extensive programming experience in C+, Java, or C#. Chapters 10 through 14 are more challenging and require more detailed lectures.Chapters 15 and 16 are entirely new to most students at the junior level. Ideally, language processors for Scheme and Prolog should be available for students required to learn the material in these chapters. Sufficient material is included to allow students to dabble with some simple programs.Undergraduate courses will probably not be able to cover all of the last two chapters in detail. Graduate courses, however, should be able to completely discuss the material in those chapters by skipping over parts of the early chapters on imperative languages.Supplemental MaterialsThe following supplements are available to all readers of this book at /cssupport. A set of lecture notes slides. PowerPoint slides are available for each chapter of the book. PowerPoint slides containing all the figures in the book. To reinforce learning in the classroom, to assist with the hands-on lab component of this course, and/or to facilitate students in a distance learning situation, access the Companion Website at /sebesta. The web site contains:1. Mini-manuals (approximately 100-page tutorials) on a handful of languages. These proceeed on the assumption that the student knows how to program in some other language, giving the student enough information to complete the chapter materials in each language. Currently, the site includes manuals for C+, C, Java, and Smalltalk.2. Self-assessment quizzes. Students complete a series of multiple-choice and fill-in-the-blank exercises to check their understanding of each chapter,.Solutions to many of the problem sets are available to qualified instructors on our Instructors Resource Center at /irc. Please contact your local Addison-Wesley sales representative, or send e-mail to , for information about how to access them.Language Processor AvailabilityProcessors for and information about some of the programming languages discussed in this book can be found at the following Web sites:C, C+, Fortran, and AC#JHS/CS/PLT/packages/drscheme/PPR/enJavaScript is included in virtually all browsers; PHP is included in virtually all Web servers. All this information is also included on the companion Web site.AcknowledgementsThe suggestions from outstanding reviewers contributed greatly to this books present form. In alphabetical order, they are:I-ping Chu, DePaul UniversityAmer Diwan,University of ColoradoStephen Edwards,Virginia TechNigel Gwee,Southern University-Baton RougeK.N. King,Georgia State UniversityDonald Kraft, Louisiana State UniversitySimon H. Lin,California State UniversityNorthridgeMark Llewellyn, University of Central FloridaBruce R. Maxim, University of MichiganDearbornGloria Melara, California State UniversityNorthridgeFrank J. Mitropoulos, Nova Southeastern UniversityEuripides Montagne,University of Central FloridaBob Neufeld,Wichita State UniversityAmar Raheja,California State Polytechnic UniversityPomonaHossein Saiedian, University of KansasNeelam Soundarajan,Ohio State UniversityPaul Tymann,Rochester Institute of TechnologyCristian Videira Lopes, University of CaliforniaIrvineSalih Yurttas, Texas A&M UniversitySpecial thanks are due to two reviewers who thoroughly analyzed the manuscript and provided many detailed comments, Amer Diwan and Bob Neufled. Numerous other people provided input for the previous editions of Concepts of Programming Languages at various stages of its development. All of their comments were useful and greatly appreciated. In alphabetical order, they are: Vicki Allan, Henry Bauer, Carter Bays, Manuel E. Bermudez, Peter Brouwer, Margaret Burnett, Paosheng Chang, John Crenshaw, Charles Dana, Barbara Ann Griem, Mary Lou Haag, Eileen Head, Ralph C. Hilzer, Eric Joanis, Hikyoo Koh, Donald Kraft, Jiang B. Liu, Meiliu Lu, Jon Mauney, Bruce R. Maxim, Robert McCoard, Dennis L Mumaugh, Michael G. Murphy, Andrew Oldroyd, Rebecca Parsons, Jeffery Popyack, Steven Rapkin, Hamilton Richard, Tom Sager, Joseph Schell, Sibylle Schupp, Mary Louise Soffa, Neelam Soundarajan, Ryan Stansifer, Steve Stevenson, Virginia Teller, Yang Wang, John M. Weiss, and Franck Xia.Matt Goldstein, Editor, Maurene Goo, Editorial Assistant, and Marilyn Lloyd, Senior Production Supervisor of Addison-Wesley, and Tammy King and Bethann Thompson at WestWords, all deserve my gratitude for their efforts to produce the eighth edition both quickly and carefully.About the AuthorRobert Sebesta is an Associate Professor in the Computer Science Department at the University of Colorado, Colorado Springs. Professor Sebesta received a B.S. in applied mathematics from the University of Colorado in Boulder and M.S. and Ph.D. degrees in Computer Science from the Pennsylvania State University. He has taught computer science for more than 36 years. His professional interests are the design and evaluation of programming languages, compiler design, and software testing methods and tools.ContentsChapter 1Preliminaries11.1Reasons for Studying Concepts of Programming Languages 21.2Programming Domains 51.3Language Evaluation Criteria 71.4Influences on Language Design 201.5Language Categories231.6Language Design Trade-offs 241.7Implementation Methods 251.8Programming Environments 33Summary Review Questions Problem Set 34Chapter 2Evolution of the Major Programming Languages392.1Zuses Plankalkl 402.2Minimal Hardware Programming: Pseudocodes 432.3The IBM 704 and Fortran 462.4Functional Programming: LISP 512.5The First Step Toward Sophistication: ALGOL 60 562.6Computerizing Business Records: COBOL 622.7The Beginnings of Timesharing: BASIC 67Interview: Alan CooperUser Design and Language Design702.8Everything for Everybody: PL/I 722.9Two Early Dynamic Languages: APL and SNOBOL 752.10The Beginnings of Data Abstraction: SIMULA 67 762.11Orthogonal Design: ALGOL 68 772.12Some Early Descendants of the ALGOLs 792.13Programming Based on Logic: Prolog 852.14Historys Largest Design Effort: Ada 872.15Object-Oriented Programming: Smalltalk 912.16Combining Imperative and Object-Oriented Features: C+ 942.17An Imperative-Based Object-Oriented Language: Java 972.18Scripting Languages: JavaScript, PHP, Python, and Ruby1012.19 A C-Based Language for the New Millennium: C# 1052.20 Markup/Programming Hybrid Languages108Summary Bibliographic Notes Review Questions Problem Set 110Chapter 3Describing Syntax and Semantics1153.1Introduction 1163.2The General Problem of Describing Syntax 1173.3Formal Methods of Describing Syntax 1193.4Attribute Grammars 134History Note1353.5Describing the Meanings of Programs: Dynamic Semantics 140History Note156Summary Bibliographic Notes Review Questions Problem Set Programming Exercises.161Chapter 4Lexical and Syntax Analysis1674.1Introduction 1684.2Lexical Analysis 1694.3The Parsing Problem 1754.4Recursive-Descent Parsing 1794.5Bottom-Up Parsing 188Summary Review Questions Problem Set Programming Exercises195Chapter 5Names, Bindings, Type Checking, and Scopes2015.1Introduction 2025.2Names 203History Note203History Note2045.3Variables 205History Note2065.4The Concept of Binding 207Interview: Rasmus LerdorfScripting Languages and Other Examples of Slick Solutions 2125.5Type Checking 2195.6Strong Typing 2195.7Type Compatibility 221History Note2215.8Scope2255.9Scope and Lifetime 2345.10Referencing Environments 2345.11Named Constants 236Summary Review Questions Problem Set Programming Exercises.239Chapter 6Data Types2476.1Introduction 2486.2Primitive Data Types 2496.3Character String Types 253History Note2556.4User-Defined Ordinal Types 2586.5Array Types 263History Note264History Note267Interview: Rasmus LerdorfThe Open Source Movement and Work Life2766.6Associative Arrays 2806.7Record Types 2826.8Union Types 2866.9Pointer and Reference Types 291History Note295Summary Bibliographic Notes Review Questions Problem Set Programming Exercises304Chapter 7Expressions and Assignment Statements3117.1Introduction 3127.2Arithmetic Expressions 313History Note3207.3Overloaded Operators 3227.4Type Conversions 324History Note3267.5Relational and Boolean Expressions 328History Note3287.6Short-Circuit Evaluation 3317.7Assignment Statements 332History Note3357.8Mixed-mode Assignment 337Summary Review Questions Problem Set Programming Exercises338Chapter 8Statement-Level Control Structures3438.1Introduction 3448.2Selection Statements 346History Note346History Note3488.3Iterative Statements 356History Note359Interview: Larry WallPart 1: Linguistics and the Birth of Perl3648.4Unconditional Branching 371History Note3728.5Guarded Commands 3728.6Conclusions 377Summary Review Questions Problem Set Programming Exercises377Chapter 9Subprograms3839.1Introduction 3849.2Fundamentals of Subprograms 3849.3Design Issues for Subprograms 3949.4Local Referencing Environments 3959.5Parameter-Passing Methods 397Interview: Larry WallPart 2: Scripting Languages in General and Perl in Particular398History Note407History Note407History Note4119.6Parameters That Are Subprogram Names 418History Note4209.7Overloaded Subprograms 4229.8Generic Subprograms 4229.9Design Issues for Functions 4299.10User-Defined Overloaded Operators 4309.11Coroutines 431History Note431Summary Review Questions Problem Set Programming Exercises433Chapter 10Implementing Subprograms43910.1The General Semantics of Calls and Returns 44010.2Implementing “Simple” Subprograms 44110.3Implementing Subprograms with Stack-Dynamic Local Variables 44310.4Nested Subprograms 451Interview: Niklaus WirthKeeping It Simple45210.5Blocks 45910.6Implementing Dynamic Scoping 461Summary Review Questions Problem Set464Chapter 11Abstract Data Types and Encapsulation Constructs46911.1The Concept of Abstraction 47011.2Introduction to Data Abstraction 47111.3Design Issues for Abstract Data Types 47411.4Language Examples 474Interview: Bjarne StroustrupC+: Its Birth, Its Ubiquitousness, and Common Criticisms47811.5Parameterized Abstract Data Types 49011.6Encapsulation Constructs 49511.7Naming Encapsulations 498Summary Review Questions Problem Set Programming Exercises503Chapter 12Support for Object-Oriented Programming50712.1Introduction 50812.2Object-Oriented Programming 50812.3Design Issues for Object-Oriented Languages 51212.4Support for Object-Oriented Programming in Smalltalk 51612.5Support for Object-Oriented Programming in C+ 519Interview: Bjarne StroustrupOn Paradigms and Better Programming52012.6Support for Object-Oriented Programming in Java 53012.7Support for Object-Oriented Progra

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论