This is not the document you are looking for? Use the search form below to find more!

Report home > Computer / Internet

Instructor’s Solutions Manual Concepts of Programming Languages 7th Ed.

5.00 (2 votes)
Document Description
Instructor's Solutions Manual for Robert W. Sebesta's Concepts of Programming Languages 7th Edition
File Details
  • Added: November, 27th 2010
  • Reads: 13283
  • Downloads: 1028
  • File size: 135.70kb
  • Pages: 51
  • Tags: concepts of programming languages, sebesta, pearson, manual, solutions
  • content preview
Submitter
  • Name: Ahmet Badin
Embed Code:

Add New Comment




Related Documents

solution manual Essentials of corporate finance, 7th edition by stephen a. Ross, randolph w westerfield, bradford d jordan

by: castsmtb, 69 pages

solution manual Essentials of corporate finance, 7th edition by stephen a. Ross, randolph w westerfield, bradford d jordan I HAVE THE FOLLOWING SOLUTIONS MANUALS & TEST BANKS. YOU CAN ...

Sebesta, chapter2, evolution of programming languages

by: serge, 66 pages

Sebesta, chapter2, evolution of programming languages

Instructor Instructors Solutions Manual Solution Manuals Test Banks Bank Answers Answer Book Textbook eBook eBooks eTextbook e-textbook International Global Edition

by: Test Bank Seller, 94 pages

Biggest Online Store and Helper on Internet to help College Student Homework assignment Study Guide solutions Exercise Answer Test Questions Final Exam Midterm Tests Quizzes Easy Good A Grade ...

Content Preview





Instructor’s Solutions Manual

to

Concepts of Programming Languages
Seventh Edition
R.W. Sebesta
















Preface

Changes to the Seventh Edition

The goals, overall structure, and approach of this seventh edition of Concepts of Programming Languages
remain the same as those of the six 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 seventh edition evolved from the sixth through several kinds of changes. To maintain the
currency of the material, some of the discussion of older programming languages has been replaced by
material on newer languages. For example, sections were added to both Chapters 1 and 2 that discuss
markup/programming hybrid languages, using XSLT and JSP as examples. A section on program proofs
using axiomatic semantics was added, including a new proof. The section on recursive descent parsing in
Chapter 4 was strengthened by adding a new parsing routine and including a trace of a complete parse
using the recursive descent algorithm. Material has been added in several places to introduce the most
interesting features of Java 5.0, including its new iterative statement its enumeration class, and its generics.
Finally, minor changes, primarily to improve clarity, were made to a large number of sections of the book.

The Vision

This 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 Outlines

Chapter 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
language—BNF. 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,

2

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 COMMON LISP,
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 Instructor

In 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 Materials

The following supplements are available to all readers of this book at www.aw.com/cssupport.
• A set of lecture notes slides. These slides are in the form of Microsoft PowerPoint source
files, one for each of the chapters of the book.
• PowerPoint slides of all the figures in the book, should you wish to create your own lecture
notes.
• 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 www.aw.come/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-grading review exercises. Using the Addison-Wesley software engine,
students can complete a series of multiple-choice and fill-in-the-blank exercises
to check their understanding of the chapter just read.
Solutions to many of the problem sets are available only to qualified instructors. Please contact
your local Addison-Wesley sales representative, or send e-mail to aw.cse@aw.com, for information about
how to access them.

Language Processor Availability

Processors for and information about some of the programming languages discussed in this book can be
found at the following Web sites:

3

C#
microsoft.com
Java
java.sun.com
Haskell

haskell.org
Scheme

www.cs.rice.edu/CS/PLT/packages/drscheme/
Perl
www.perl.com
JavaScript 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.

Acknowledgements

The suggestions from outstanding reviewers contributed greatly to this book’s present form. In alphabetical
order, they are:
Liang Cheng,
Lehigh University
Amer Diwan,
University of Colorado
Nigel Gwee,
Louisiana State University
John V. Harrison, University of Nevada, Las Vegas
Leon Jololian, New Jersey City University
K.N. King, Georgia State University
Donald Kraft,
Louisiana State University
Simon H. Lin,
California State University, Northridge
Meilu Lu,
California State University, Sacramento
Amar Raheja,
California Polytechnic University
Hossein Saiedian, University of Kansas
Raghvinder Sangwan,
Penn State University
Young Park,
Bradley University
Steve J. Phelps, California State Univeristy, Fullerton
Yang Wang,
Southwest Missouri State University
Franck Xia,
University of Missouri-Rolla
Salih Yurttas,
Texas A&M University
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 Salih Yurttas.
Matt Goldstein, Editor, Katherine Harutunian, Project Editor, and Pat Mahtani, Production
Supervisor at Addison-Wesley, and Daniel Rausch and Edalin Michael at Argosy, all deserve my gratitude
for their efforts to produce the seventh edition both quickly and carefully.
Finally, I thank my children, Jake and Darcie, for their patience in enduring my absence from
them throughout the endless hours of effort I invested in writing the seven editions of this book.

About the Author

Robert 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 Compuer Science from the Pennsylvania State
University. He has taught computer science for more than 34 years. His professional interests are the
design and evaluation of programming languages, compiler design, and software testing methods and tools.

4

Contents
Chapter 1
Preliminaries


1
1.1

Reasons for Studying Concepts of Programming Languages
2
1.2

Programming Domains 5
1.3

Language Evaluation Criteria 7
1.4

Influences on Language Design 20
1.5
Language
Categories
23
1.6

Language Design Trade-offs
24
1.7

Implementation Methods
25
1.8
Programming
Environments

33
Summary • Review Questions • Problem Set


34

Chapter 2
Evolution of the Major Programming Languages 39
2.1
Zuse’s
Plankalkül
40
2.2

Minimal Hardware Programming: Pseudocodes 43
2.3

The IBM 704 and Fortran
45
2.4

Functional Programming: LISP 52
2.5

The First Step Toward Sophistication: ALGOL 60
57
2.6

Computerizing Business Records: COBOL
63
2.7

The Beginnings of Timesharing: BASIC
68
Interview: Alan Cooper—User Design and Language Design
72
2.8

Everything for Everybody: PL/I 74
2.9

Two Early Dynamic Languages: APL and SNOBOL
78
2.10

The Beginnings of Data Abstraction: SIMULA 67
79
2.11

Orthogonal Design: ALGOL 68 80
2.12

Some Early Descendants of the ALGOLs
82
2.13

Programming Based on Logic: Prolog 90
2.14

History’s Largest Design Effort: Ada
92
2.15

Object-Oriented Programming: Smalltalk
97
2.16

Combining Imperative and Object-Oriented Features: C++
101
2.17

An Imperative-Based Object-Oriented Language: Java 104
2.18

Scripting Languages: JavaScript, PHP, and Python
108
2.19

A C-Based Language for the New Millennium: C#
112
2.20

Markup/Programming Hybrid Languages
115
Summary • Bibliographic Notes • Review Questions •Problem Set


117

Chapter 3
Describing Syntax and Semantics
123
3.1
Introduction

124
3.2

The General Problem of Describing Syntax
125
3.3

Formal Methods of Describing Syntax 127
3.4
Attribute
Grammars

141
History
Note
142

3.5

Describing the Meanings of Programs: Dynamic Semantics
148
History
Note
164
Summary • Bibliographic Notes • Review Questions • Problem Set •
Programming Exercises

.......................................................................169

Chapter 4
Lexical and Syntax Analysis



175
4.1
Introduction

176
4.2
Lexical
Analysis
177

5

4.3

The Parsing Problem 181
4.4

Recursive-Descent Parsing
185
4.5
Bottom-Up
Parsing
193
Summary • Review Questions • Problem Set •Programming Exercises


200

Chapter 5
Names, Bindings, Type Checking, and Scopes


205
5.1
Introduction

206
5.2
Names

207
History
Note
207
History
Note
208
5.3
Variables
209
History Note


210
5.4

The Concept of Binding
212
Interview: Rasmus Lerdorf—Scripting Languages and Other Examples of Slick Solutions 216
5.5

Type Checking 222
5.6

Strong Typing 223
5.7

Type Compatibility
225
History
Note
225
5.8
Scope
228
5.9

Scope and Lifetime
237
5.10

Referencing Environments
237
5.11

Named Constants
239
Summary • Review Questions • Problem Set • Programming Exercises


....242

Chapter 6
Data Types


251
6.1
Introduction

252
6.2

Primitive Data Types 253
6.3

Character String Types 256
History
Note
258
6.4

User-Defined Ordinal Types
261
6.5

Array Types
266
History
Note
267
History Note


269
6.6

Associative Arrays
279
Interview: Rasmus Lerdorf—The Open Source Movement and Work Life

280
6.7
Record
Types

284
6.8
Union
Types

288
6.9

Pointer and Reference Types
292
History
Note
296
Summary • Bibliographic Notes • Review Questions •
Problem Set •Programming Exercises


305

Chapter 7
Expressions and Assignment Statements 311
7.1
Introduction

312
7.2
Arithmetic
Expressions

313
History Note


320
7.3

Overloaded Operators 321
7.4

Type Conversions
323
History Note


324
7.5

Relational and Boolean Expressions
326

6

History Note


326
7.6

Short-Circuit Evaluation
329
7.7
Assignment
Statements

330
History Note


333
7.8
Mixed-mode
Assignment
334
Summary • Review Questions • Problem Set • Programming Exercises


....335

Chapter 8
Statement-Level Control Structures



341
8.1
Introduction

342
8.2

Selection Statements
343
History Note


344
History Note


346
8.3

Iterative Statements
352
History Note


354
Interview: Larry Wall—Part 1: Linguistics and the Birth
of Perl
362
8.4
Unconditional
Branching
366
History Note


366
8.5

Guarded Commands
367
8.6
Conclusions

371
Summary • Review Questions • Problem Set •Programming Exercises


372

Chapter 9
Subprograms


377
9.1
Introduction

378
9.2

Fundamentals of Subprograms 378
9.3

Design Issues for Subprograms 385
9.4

Local Referencing Environments
385
9.5

Parameter-Passing Methods
387
Interview: Larry Wall—Part 2: Scripting Languages in General and Perl in Particular
388
History Note


396
History Note


397
History Note


401
9.6

Parameters That Are Subprogram Names
408
History
Note
409
9.7

Overloaded Subprograms
410
9.8
Generic
Subprograms

411
9.9

Design Issues for Functions
417
9.10

User-Defined Overloaded Operators
418
9.11
Coroutines
419
History Note


419
Summary • Review Questions • Problem Set •Programming Exercises


421

Chapter
10
Implementing
Subprograms
427
10.1

The General Semantics of Calls and Returns
428
10.2

Implementing “Simple” Subprograms 429
10.3

Implementing Subprograms with Stack-Dynamic Local Variables
431
10.4
Nested
Subprograms
439
Interview: Niklaus Wirth—Keeping It Simple
440
10.5
Blocks

447
10.6

Implementing Dynamic Scoping
449

7

Summary • Review Questions • Problem Set


453

Chapter 11
Abstract Data Types and Encapsulation Constructs


459
11.1

The Concept of Abstraction
460
11.2

Introduction to Data Abstraction
461
11.3

Design Issues for Abstract Data Types 463
11.4

Language Examples
464
Interview: Bjarne Stroustrup—C++: Its Birth, Its
Ubiquitousness, and Common Criticisms

.466
11.5

Parameterized Abstract Data Types
478
11.6
Encapsulation
Constructs

481
11.7
Naming
Encapsulations

484
Summary • Review Questions • Problem Set •Programming Exercises


488

Chapter 12
Support for Object-Oriented Programming



493
12.1
Introduction
494
12.2

Object-Oriented Programming 494
12.3

Design Issues for Object-Oriented Languages 497
12.4

Support for Object-Oriented Programming in Smalltalk 502
12.5

Support for Object-Oriented Programming in C++
504
Interview: Bjarne Stroustrup—On Paradigms and
Better Programming

506
12.6

Support for Object-Oriented Programming in Java
514
12.7

Support for Object-Oriented Programming in C#
517
12.8

Support for Object-Oriented Programming in Ada 95
519
12.9

The Object Model of JavaScript 524
12.10
Implementation of Object-Oriented Constructs 527
Summary • Review Questions • Problem Set •Programming Exercises


530

Chapter 13
Concurrency


535
13.1
Introduction
536
13.2

Introduction to Subprogram-Level Concurrency 539
13.3
Semaphores
543
History Note


543
13.4
Monitors

548
13.5
Message
Passing

550
13.6

Ada Support for Concurrency 551
13.7

Java Threads 562
13.8

C# Threads
570
13.9
Statement-Level
Concurrency

572
Summary • Bibliographic Notes • Review Questions • Problem Set •
Programming Exercises

574

Chapter 14
Exception Handling and Event Handling


579
14.1

Introduction to Exception Handling
580
History Note


584
14.2

Exception Handling in Ada
586
14.3

Exception Handling in C++
593
14.4

Exception Handling in Java
597

8

Interview: James Gosling—The Birth of Java

600
14.5

Introduction to Event Handling 607
14.6

Event Handling with Java
608
Summary • Bibliographic Notes • Review Questions • Problem Set .........614

Chapter 15
Functional Programming Languages



619
15.1
Introduction
620
15.2

Mathematical Functions
621
15.3

Fundamentals of Functional Programming Languages
623
15.4

The First Functional Programming Language: LISP
624
15.5

An Introduction to Scheme
628
15.6
COMMON
LISP

645
15.7
ML
645
15.8
Haskell

649
15.9

Applications of Functional Languages 653
15.10
A Comparison of Functional and Imperative Languages 653
Summary • Bibliographic Notes • Review Questions • Problem Set •
Programming Exercises

654

Chapter 16
Logic Programming Languages


659
16.1
Introduction
660
16.2

A Brief Introduction to Predicate Calculus
660
16.3

Predicate Calculus and Proving Theorems
664
16.4

An Overview of Logic Programming
666
16.5

The Origins of Prolog 668
16.6

The Basic Elements of Prolog 669
16.7

The Deficiencies of Prolog
684
16.8

Applications of Logic Programming
689
Summary • Bibliographic Notes • Review Questions • Problem Set •
Programming Exercises 691
Bibliography

695
Index

705




9

Answers to Selected Problems

Chapter 1
Problem Set:
3. Some arguments for having a single language for all programming domains are: It
would dramatically cut the costs of programming training and compiler purchase and
maintenance; it would simplify programmer recruiting and justify the development of
numerous language dependent software development aids.
4. Some arguments against having a single language for all programming domains are:
The language would necessarily be huge and complex; compilers would be expensive
and costly to maintain; the language would probably not be very good for any
programming domain, either in compiler efficiency or in the efficiency of the code it
generated. More importantly, it would not be easy to use, because regardless of the
application area, the language would include many unnecessary and confusing features
and constructs (those meant for other application areas). Different users would learn
different subsets, making maintenance difficult.
5. One possibility is wordiness. In some languages, a great deal of text is required for
even simple complete programs. For example, COBOL is a very wordy language. In
Ada, programs require a lot of duplication of declarations. Wordiness is usually
considered a disadvantage, because it slows program creation, takes more file space for
the source programs, and can cause programs to be more difficult to read.
7. The argument for using the right brace to close all compounds is simplicity—a right
brace always terminates a compound. The argument against it is that when you see a right
brace in a program, the location of its matching left brace is not always obvious, in part
because all multiple-statement control constructs end with a right brace.
8. The reasons why a language would distinguish between uppercase and lowercase in its
identifiers are: (1) So that variable identifiers may look different than identifiers that are
names for constants, such as the convention of using uppercase for constant names and
using lowercase for variable names in C, and (2) so that catenated words as names can
have their first letter distinguished, as in TotalWords. (Some think it is better to include
a connector, such as underscore.) The primary reason why a language would not
distinguish between uppercase and lowercase in identifiers is it makes programs less
readable, because words that look very similar are actually completely different, such as
SUM and Sum.
10. One of the main arguments is that regardless of the cost of hardware, it is not free.
Why write a program that executes slower than is necessary. Furthermore, the difference
between a well-written efficient program and one that is poorly written can be a factor of
two or three. In many other fields of endeavor, the difference between a good job and a
poor job may be 10 or 20 percent. In programming, the difference is much greater.
15. The use of type declaration statements for simple scalar variables may have very little
effect on the readability of programs. If a language has no type declarations at all, it may
be an aid to readability, because regardless of where a variable is seen in the program
text, its type can be determined without looking elsewhere. Unfortunately, most
languages that allow implicitly declared variables also include explicit declarations. In a

10

Download
Instructor’s Solutions Manual Concepts of Programming Languages 7th Ed.

 

 

Your download will begin in a moment.
If it doesn't, click here to try again.

Share Instructor’s Solutions Manual Concepts of Programming Languages 7th Ed. to:

Insert your wordpress URL:

example:

http://myblog.wordpress.com/
or
http://myblog.com/

Share Instructor’s Solutions Manual Concepts of Programming Languages 7th Ed. as:

From:

To:

Share Instructor’s Solutions Manual Concepts of Programming Languages 7th Ed..

Enter two words as shown below. If you cannot read the words, click the refresh icon.

loading

Share Instructor’s Solutions Manual Concepts of Programming Languages 7th Ed. as:

Copy html code above and paste to your web page.

loading