CSC 351 - Chapter 7 Flashcards
expression
the fundamental means of specifying computations in a programming language
arithmetic expressions
consist of operators, operands, parentheses and function calls
unary
single operand
binary
two operands
ternary
three operands
infix
operators appear between their operands
prefix
operators precede their operands
operator precedence rules
define the order in which the operators of different precedence rules are evaluated. based on a hierarchy of operator priorities
identity operator
unary addition - usually has no associated operation therefore having no affect on its operand
associativity
when an expression contains two operators of the same precedence next to each other, the associativity rules of the language determine which operator gets evaluated first (common to go left to right)
parenthesis
can alter the precedence and associativity rules by being added to an expression
side effect
occurs when the function changes either one of its parameters or a global variable
referential transparency
occurs if any two expressions in the program that have the same value can be substituted for one another without affecting the program. adv: the semantics are much easier to understand
operator overloading
multiple use of an operator - acceptable as long as the readability nor reliability suffers
narrowing conversion
converts a value to a type that cannot store even approximations of all the values of the original type