2013-06-22

Programming Language Concept (7)

Book : Concept of Programming Language

Page 342
Review Question
1. Define operator precedence and operator associativity.
operator precedence :expression evaluation partially define
the order in which the operators of different precedence levels are evaluated.
operator associativity:When an expression contains two adjacent
occurrences of operators with the same level of precedence, the question of which operator is evaluated first

3.What is a prefix operator?
the operator precede the operands

5. What operator usually has right associativity?
the indices never need to be stored

6. What associativity rules are used by APL?
all operators have the same level of
precedence. Thus, the order of evaluation of operators in APL expressions is
determined entirely by the associativity rule, which is right to left for all operators.

8. Define functional side effect.
A side effectof a function, naturally called a functional side effect,occurs when the function changes either one of its parameters or a global variable. (A global
variable is declared outside the function but is accessible in the function.

44. Define type error.
type erroris the application of an operator to an operand of an inap-propriate type.

45. Define strongly typed.
widely acknowledged as being a highly valuable language characteris-tic

47. What is a nonconverting cast?
extracting the value of a variable of one type and using it as if it were of a different type

48. What languages have no type coercions?
Ada

49. Why are C and C++ not strongly typed?
because both include union types, which are not type checked.

Page 343
Problem Set
1. When might you want the compiler to ignore type differences in an expression?
run time

3.Do you think the elimination of overloaded operators in your favorite language would be beneficial?Why or why not?
no, because operator need to multiply use the operator, so it won’t be hard to use the operator again and again

4. Would it be a good idea to eliminate all operator precedence rules and
require parentheses to show the desired precedence in expressions? Why
or why not?
no, because it partially define the order in which the operators of different precedence levels are evaluated

11. In the Burroughs Extended ALGOL language, matrices are stored as a
single-dimensioned array of pointers to the rows of the matrix, which are
treated as single-dimensioned arrays of values. What are the advantages
and disadvantages of such a scheme?
The advantage of this scheme is that accesses that are done in order of the rows can
be made very fast; once the pointer to a row is gotten, all of the elements of the row can
be fetched very quickly. If, however, the elements of a matrix must be accessed in
column order, these accesses will be much slower; every access requires the fetch of a
row pointer and an address computation from there. Note that this access technique was
devised to allow multidimensional array rows to be segments in a virtual storage
management technique. Using this method, multidimensional arrays could be stored and
manipulated that are much larger than the physical memory of the computer.

15. What are the arguments for and against Head management’s single-size cells and variable-size cells?
Integer values stored in decimal waste storage in binary memory computers, simply as
a result of the fact that it takes four binary bits to store a single decimal digit, but those
four bits are capable of storing 16 different values. Therefore, the ability to store six out
of every 16 possible values is wasted. Numeric values can be stored efficiently on binary
memory computers only in number bases that are multiples of 2. If humans had
developed hands with a number of fingers that was a power of 2, these kinds of problems
would not occur.

21. In what way is dynamic type checking better than static type checking?
run time

Tidak ada komentar:

Posting Komentar