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
widening conversion
converts a value to a type that can include at least approximations of all the values of the original type
mixed-mode expression
languages that allow operators to have operands of different types
relational operator
operator that compares the values of its two operands, the value of a relational expression is a boolean
short-circuit evaluation
a result is determines without evaluating all of the operands and/or operators
compound assignment operator
a shorthand method of specifying a commonly needed form of assignment
coercion
an implicit type conversion that is initiated by the compiler
Always does short-circuit evaluation
Ruby
Allows the programmer to choose if they want to use short-circuit evaluation
Ada