Tuesday, November 4, 2014

Chapter 5 : Review Question

Q6 : What is the l-value of a variable? What is the r-value?
A   : L-value is the address of a variable , because the address is what is required when the name of a variable appears in the left side of an assignment.
R-value is a name for a variable's value because it is what is required when the name of the variable appears in the right side of an assignment statement.

Q7 : Define binding and binding time.
A   : A binding is an association between an attribute and an entity, such as between a variable and its type or value, or between an operation and a symbol.
Binding time is the time at which a binding takes place.

Q8 : After language design and implementation [what are the four times bindings can take place in a program?]
A   :
-compile time (bind a variable to a type in C or Java)
-link time
-load time (bind a C or C++ static variable to a memory cell)
-run time (bind a nonstatic local variable to a memory cell)

Q9 : Define static binding and dynamic binding.
A   : A static binding is if it first occurs before run time and remains unchanged throughout program execution. A dynamic binding is if it first occurs during execution or can change during execution of the program.

Q10 : What are the advantages and disadvantages of implicit declarations?
A     :
Advantages:
-Can make it easier for the programmer to write code, since he/she doesn’t have to also write the declarations
-Maintainability can be easier too, since the information about a variable’s type is not written down in a part of the program distant from where the variable is used
-Readability can be better since a reader can probably infer the variable’s name or its context

Disadvantage:

-Reliability will probably suffer since the programmer may not always realize the type that the compiler assigned a variable

No comments:

Post a Comment