Chapter 06 - Chapter 06 Chapter 6 Operator precedence are...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 06 Chapter 6 Operator precedence are rules for expression evaluation that define the order in which the operators of different precedence levels are evaluated. Example: A + (-b) * C Operator associativity is the rules of the language which determine, when there are two adjacent occurrences of operators of the same level of precedence, which operator is evaluated first. Example: A – B + C – D Functional Side Effect (the side effect of a function), occurs when the function changes either one of its parameters or a global variable. Example: A + FUN(A) (This works only if FUN changes A, then there is an effect) Coercion is the implicit type conversion that occurs when two operands of an operator are not of the same type (and that’s legal in the language) and the compiler must choose one of them to be coerced and supply the proper code for the coercion. Conditional expression is an assignment statement of the general form expression_1 ? expression_2: expression_3 (if-then-else). Conditional expression, ternary operator, ?: which is used to form conditional ezpressions. Sometimes if-then-else statements are used to perform conditional expressions. Example: average = (count ==0) ? 0: sum / count; Overloaded operator is an operator that has multiple purposes assigned to it, i.e. , in Java, + is used both for numeric additon and for string concatenation. Example: x = &y; Type conversions are either narrowing conversions (where a value is converted to a type that cannot store all of the values of the original type) or widening conversions (where a value is converted to a type that can inclued at least approximations of all of the values of the original type – int to a float, in C). A mixed mode expression is where and operator has operands of different types. Functional side effects occur when operational evaluation order is not specified by the designer of the language to preclude ambiguous results depending on what part of the expression is evaluated first. A short-ciruit evaluation of an expression is one in which the result is determined without evaluation all of the operands and/or operators, i.e., an and statement where the first part is false and therefore the entire statement is false regardless of the value of the second part of the and statement. Modula 2 always does short-circuit evaluation: Pascal never does short-circuit evaluation: in
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/30/2011 for the course CS 317 taught by Professor Ismaelhomade during the Spring '11 term at Jordan University of Science & Tech.

Page1 / 5

Chapter 06 - Chapter 06 Chapter 6 Operator precedence are...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online