Chapter 7 Flashcards
What is an expression?
The fundamental means of specifying computations in a programming language.
What is an operator?
A character that represents a specific mathematical or logical action or process.
What are the three types of operators?
-Unary
-Binary
-Ternary
How is order of operation determined?
Operator precedence rules
What can be used to change the default order of operation?
Parenthesis
What is a conditional expression? How are they implemented or written in various languages?
An expression you can use to select one of two values based on a boolean condition. Examples include if statements, guards in haskell, cond in racket, etc.
What is a side-effect?
When a function either changes one of its parameters or a global variable.
How can side-effects complicate expression evaluation?
If a variable is being referenced while being altered in a function, what is the value of the variable?
What is an overloaded operator?
Using the same operator for multiple purposes. For example, “+” in Java can add numbers or concatenate strings, “&” in C and C++ for binary operations and pointer stuff
What is type conversion?
The narrowing or widening of what a variable can hold
When does type conversion typically take place?
In an expression with more than 1 data types
What is a relational expression?
An operator that compares the values of its two operands. X < 7, Y > 6.
What is a Boolean expression?
-Expressions consisting of boolean variables
-Boolean constants
-Relational expressions
-Boolean operators that produce boolean values.
What is short-circuit evaluation?
An expression where the result was determined without evaluating all operators. For example, an IF statement with an AND clause but doesn’t need to evaluate the second part of the AND
How can short-circuit evaluation be used to protect an expression?
It can prevent errors that are caused by future expressions. For example, the expression while((index < listlen) && (list[index] != key)). If this wasn’t short-circuit evaluated, the there would eventually be an out of bounds error when index = listlen.