Chapter 7 Flashcards

1
Q

What do we need to know in order to understand expression evaluation?

A

The order of operator and operand evaluation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What was the biggest reason people wanted to develop programming languages?

A

Arithmetic evaluations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

2 biggest questions when designing arithmetic expressions.

A

Operator precedence rules (order)
operator associativity rules (left-to-right or r-t-l)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How many operators does a unary, binary and ternary have?

A

1,2,3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How many precedence levels does APL have?

A

1 ( right to left)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can you override precedence + associativity rules?

A

(In most languages) Parentheses

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Problem with operators in Ruby?

A

Methods. Can overwrite the methods

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the operand evaluation order?

A

Variables
Constants
Parenthesized expressions
Side effects?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the problem with operator overloading?

A

Decreased readability and writeability

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Whats the difference between narrowing conversions and widening conversions with type conversions?

A

Narrowing = Cant include all original values ( float to int)
Widening = int to float

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a mixed mode expression?

A

2 different type values are added together

A = int, B = float. A + B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is Coercion?

A

Auto type conversion

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is bad about coercion?

A

Decrease in reliability

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What kinds of errors can coercion create?

A

Run time errors, since it cant be checked beforehand

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does no coercion imply?

A

Extreme type safety

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What type of conversion is casting in C?

A

Explicit type conversion

17
Q

What does relational expressions do?

A

Evaluate to booleans

18
Q

Equality for coercion and without coercion in Ruby

A

== for coercion ( == in JS )
elq? for no coercion ( === in JS)

19
Q

What is short circuit evaluation?

A

Dont evaluate entire thing if 1st part fails
(13 * a) * ( b + c)
If a = 0 then dont evaluate the rest

20
Q

What is the problem with non short-circuit evaluation?

A

Additional performance overhead

21
Q

What is the problem with short-circuit evaluation?

A

If side effects are expected

22
Q

What are conditional targets?

A

if statement but with “immediate” assignment.

(flag ? total : subtotal) = 0
(flag -> true = total = 0)

22
Q

Possible problem with assignment statements?

A

If you overload it it can become ambiguous languages have == for relational

23
Q

What is a compound assignment operator?

24
What is a unary assignment operator?
++
25
What is the problem with having an assignment as a expression? if ( x=y ){}
Reduces error detection Side effects
26
When do side effects happen?
When a global variable is changed or a function parameter
27
What is a non-associative operator?
If its not used in the same order it will give different results 2-1 and 1-2 Thus - is non-associative