Monday, April 8, 2013

Chapter 5 - Names, Bindings, and Scopes

Review Question
1. - 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. - 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.- 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.
6.-value is the address of a variable. r-value is a variable’s value that’s required when the name of the variable appears in the right side of an assignment statement.
7. 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.
16. The referencing environment of a statement is the collection of all variables that are visible in the statement.
Problem Set
1.The valid identifier names are _Student, Student, and Student123. We cannot use ‘int’ as name because it’s a reserved keyword and we cannot use the 123Student because C doesn’t allow identifier format with a digit at the first letter.
2.n 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.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.

No comments:

Post a Comment