Chapter 5 Problems



Chapter 5 Review Questions

1. What are the design issues for names?
- The following are the primary design issues for names:
• Are names case sensitive?
• Are the special words of the language reserved words or keywords?
These issues are discussed in the following two subsections, which also include
examples of several design choices.


2. What is the potential danger of case-sensitive names?
- In that sense, case sensitivity violates the design principle that language constructs that look similar should have similar meanings. But in languages whose variable names are case-sensitive, although Rose and rose look similar, there is no connection between them.

3. In what way are reserved words better than keywords?
- A reserved word is a special word of a programming language that cannot be used as a name. As a language design choice, reserved words are better than keywords because the ability to redefine keywords can be confusing.

4. What is an alias?
When more than one variable name can be used to access the same memory location, the variables are called aliases. Aliasing is a hindrance to readability because it allows a variable to have its value changed by an assignment to a different variable.

6. What is the l-value of a variable? What is the r-value?
- The value of a variable is the contents of the memory cell or cells associated with the variable. It is convenient to think of computer memory in terms of abstract cells, rather than physical cells. A variable’s value is sometimes called its r-value because it is what is required when the name of the variable appears in the right side of an assignment statement.

7. Define binding and binding time.
- A binding is an association between an attribute and an entity, such as etween a variable and its type or value, or between an operation and a symbol. The time at which a binding takes place is called binding time. Binding and binding times are prominent concepts in the semantics of programming languages.

Problem Set

2. What is an l-value? Write a statement in C language which gives the compile time error “l-valued required”.
- An lvalue is a way of describing the term on the left hand side of an assignment. It is usually an address or variable.
if (0 = foo)
{

}

4. Why is the type declaration of a variable necessary? What is the value range of the int type variable in Java?
- A data type, such as int in C, is bound to a range of values at language implementation time. At compile time, a variable in a Java program is bound to a particular data type. A variable may be bound to a storage cell when the program is loaded into memory. That same binding does not happen until run time in some cases, as with variables declared in Java methods. A call to a library subprogram is bound to the subprogram code at link time.

5. Describe a situation each where static and dynamic type binding is required.
- In static binding, for example, in Fortran, an identifier that appears in a program that is not explicitly declared is implicitly declared according to the following convention: If the identifier begins with one of the letters I, J, K, L, M, or N, or their lowercase versions, it is implicitly declared to be Integer type; otherwise, it is implicitly declared to be Real type.