Chapter 6.9 Flashcards

(13 cards)

1
Q

What is a compatible type?

A

A type that is either legal for the operator or can be implicitly converted (coerced) to a legal type.

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

Define type error.

A

The application of an operator to an operand of an inappropriate type.

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

Define strongly typed.

A

A language is strongly typed if type errors are always detected.

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

Why is Java not strongly typed?

A

Although strictly typed, the text notes that its extensive coercion (e.g., float + int) weakens the value of error detection associated with strong typing.

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

What is a nonconverting cast?

A

It is a conversion (like Ada’s Unchecked_Conversion) that extracts the value of a variable of one type and uses it as if it were another type without actual conversion.

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

What languages have no type coercions?

A

ML and F#.

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

Why are C and C++ not strongly typed?

A

Because they include union types which are not type checked.

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

What is name type equivalence?

A

Variables have equivalent types if they are defined in the same declaration or use the same type name.

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

What is structure type equivalence?

A

Variables have equivalent types if their types have identical structures.

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

What is the primary advantage of name type equivalence?

A

It is easy to implement.

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

What is the primary disadvantage to structure type equivalence?

A

It is difficult to implement (requires comparing entire structures) and breaks the ability to differentiate between types that happen to have the same structure but different meanings (e.g., Celsius vs. Fahrenheit).

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

For what types does C use structure type equivalence?

A

For nonscalar types other than struct, enum, and union (such as arrays).

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

What set operation models C’s struct data type?

A

The Cartesian (or cross) product.

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