Concepts of Programming Languages 11th Ed
Concepts of Programming Languages 11th Ed
lstonsere
'
deimaludye . iuo
… P hh精 存
tatesob
1. What are the arguments for and against representing Boolean values as
single bits in memory?
2. How does a decimal value waste memory space? one dig
v 7 tabyt
tesopesereatio
sforese
take onorf mas
'
Tx
3. VAX minicomputers use a format for floating-point numbers that is
not the same as the IEEE standard. What is this format, and why was
least decnral
4u bit
wigie
code
it chosen by the designers of the VAX computers? A reference for VAX
floating-point representations is Sebesta (1991).
4. Compare the tombstone and lock-and-key methods of avoiding dangling
pointers, from the points of view of safety and implementation cost.
僅發⽣在某些上⽂中時 0
5. What disadvantages are there in implicit dereferencing of pointers, but
降低language 可素性 only in certain contexts?
6. Explain all of the differences between Ada’s subtypes and derived types.
⽤於訪問指向结構 or ←ψ 7. What significant justification is there for the -> operator in C and C++?
類指針的成員 使程式 c 8.,
vWhat are all of the differences between the enumeration types of C++
and those of Java?
易
法 , 改值類数型範圈法 Y )9. Multidimensional arrays can be stored in row major order, as in C++, or
途代器⽀援订右
(
。 更⾼memysafe
和默效 treated as single-dimensioned arrays of values. What are the advantages
0 型别安链⽩動虔理型别换 V X
and disadvantages of such a scheme?
0⽀摇星常虚理 11. Analyze and write a comparison of C’s malloc and free functions with
C++’s new and delete operators. Use safety as the primary consideration
malloc in the comparison.
⼿動管vet
uwsncnalou
安全
便利内存直接 antrol ,
⽅便零活
⼿动 需出錯
(t+
ctt
分配内建回收
:
p r o g r a m m i N g e x e r c i S e S
P r o b l e m S e t
a .
Alse of values is to be addedto d SUM ,
apresciibefdmber
the neading is to Terinate whey lither
of ialnes have blen nead
specpal value
2. Study the iterator feature of CLU in Liskov et al. (1981) and determine
or some
ouintaiorgiifhrorrgi
uitbmghintkmshi
mid
bwr n ton
WiolMi nontptiflI
V
3. Compare the set of Ada control statements with those of C# and decide
mrbsihautooo 是
which are better and why.
4. What are the pros and cons of using unique closing reserved words on
compound statements?
ComTvol Statememe s the most
Cd
flexiby
ratonstqternent , RMaf 4 sple seleaton
5. What are the arguments, pros and cons, for Python’s use of indentation
woictabikty
#
c
可讀簡得强制规節名
敏弛不适⽤被穿就讨播
6. Analyze the potential readability problems with using closure reserved
words for control statements that are the reverse of the corresponding initial
ue reserved words, such as the case-esac reserved words of ALGOL 68. For
example, consider common typing errors such as transposing characters.
7. Use the Science Citation Index to find an article that refers to Knuth
(1974). Read the article and Knuth’s paper and write a paper that sum-
marizes both sides of the goto issue.
386 Chapter 8 Statement-Level Control Structures
8. In his paper on the goto issue, Knuth (1974) suggests a loop control
statement that allows multiple exits. Read the paper and write an opera-
tional semantics description of the statement.
9. What are the arguments both for and against the exclusive use of Bool-
ean expressions in the control statements in Java (as opposed to also
allowing arithmetic expressions, as in C++)?
找⽬標榜 ← 10. Describe a programming situation in which the else clause in Python’s
for statement would be convenient.
显限迪国⾄少
exeante
*
←
11. Describe three specific programming situations that require a posttest loop.
12. Speculate as to the reason control can be transferred into a C loop statement.
资料虎理
P r o g r a m m i n g e x e r c i S e S
k = (j + 13) / 27
loop:
if k > 10 then goto out
k = k + 1
i = 3 * k - 1
goto loop
out: . . .
a. C, C++, Java, or C#
b. Python
c. Ruby
Assume all variables are integer type. Discuss which language, for this
code, has the best writability, the best readability, and the best combin-
ation of the two.
2. Redo Programming Exercise 1, except this time make all the variables
and constants floating-point type, and change the statement
k = k + 1
to
k = k + 1.2
if ((k == 1) || (k == 2)) j = 2 * k - 1
if ((k == 3) || (k == 5)) j = 3 * k + 1
if (k == 4) j = 4 * k - 1
if ((k == 6) || (k == 7) || (k == 8)) j = k - 2