Monday 15 April 2013

Chapter 7 - Concept of Programming Languages Tenth Edition - Robert Sebesta

Review Question Chapter 7


5. What is a nonassocative operator?

A nonassociative operator means that the expression is illegal.


6. What associativity rules are used by APL?

all operators have equal precedence and all operators associate right to left.


8. Define functional side effect.

Functional side effect occurs when the function changes either one of its parameters or a global variable.


9. What is coercion?

A coercion is an implicit type conversion.


10. What is a conditional expression?

a conditional expression is a statement that contains if-then-else to perform a conditional expression assignment.

14. What is a mixed-mode expressions?

A mixed-mode expressions is a programming language that allows an operator to have operands of different types.


28. What is a cast

A cast in C-based languages, is an explicit type conversions.



Problem Set Chapter 7


1. When might you want the compiler to ignore type differences in an expressions?

When i wanted to do an operation, for example : char array with an integer (string + integer), however this is not possible and we must first convert the char array into integer(typecasting) and after that we can do the operation.


3. Do you think the elimination of overloaded operators in your favorite language would be beneficial? Why or why not?

Yes, I do think that the elimination of overloaded operators in my favorite language would be beneficial.

Elimination of overloaded operators would:

- Enhance and increase readability.

- Minimize the compiler overhead (choosing the correct operator meaning).


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?

I against this idea. The amount of parentheses needed will have an impact to readability, and it will also made the programmer have more work to write the parentheses down, when you can just type it the standard way. After all that's how the math's work


5. Should C’s assigning operations (for example, +=) be included in other languages (that do not already have them)? Why or why not?
Personally, i myself prefer to use x = x + y due to the readability, some people uses x += y. But it still okay to implement this type of operator in other languages.


7. Describe a situation in which the ad operator in a programming language would not be communicative

An expression such as x + fun(y).


21. Why does Java specify that operands in expressions are all evaluated in left-to-right order ?

Java has well defined rules for specifying order in which in expression are all evaluated in left-to-right order, this is done to make Java easier to code, as left-to-right order is how most of us learned it in our early school on the mathematics subject. left-to-right order is also one of the most used guidelines in order to evaluate operands in an expression. This is also done to prevent functional side effect from happening.

No comments:

Post a Comment