Chapter 9 Flashcards

1
Q

What are the 2 types of abstraction?

A

Process abstraction
Data abstraction

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

What are the fundamentals of subprograms?

A

Single point of entry
If subprogram is called, calling program is suspended
After execution control is returned to the caller

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

Basic definition for subprograms

A

Defines interface and action
Interface specifies how the subprogram is used + name + parameters +…
Actions: Specify hat it does (body)

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

What is a subprogram header?

A

The 1st part of the subprogram definition.
Name kind parameters

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

What is the difference between formal parameters and actual parameters?

A

Formal: Dummy variable in header. Used in subprogram
Actual: Values being passed in

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

What is a parameter profile(signature)?

A

Number, order and types of parameters

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

What is a protocol?

A

Parameter profile with function return types

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

What is a subprogram declaration?

A

Provides subprogram protocol, but not its body (prototype (void doSomething(int);)

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

What is the Parameter correspondence?

A

for a subprogram call we must match actual parameters to formal parameters.

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

What is the advantage of Positional parameters?

A

1st parameter = 1st parameter etc…
It is safe and effective

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

What is the disadvantage of Positional parameters?

A

reduced readability + error prone

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

What is the advantage + disadv of Keyword parameters?

A

Adv: Avoid corespondence errors. can appear in any order (improved readability)
Dis: Memorize param names

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

Can formal parameters have default values?

A

Yes

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

How are variable number of parameters processed?

A

Like a list

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

What are the 2 categories of subprograms?

A

Procedures (collections of statements that define parameterized computations)
Functions (resemble procedures but semantically modeled on mathematical functions)

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

How does Procedures and functions differ?

A

Procedures: produce result by modifying
Functions: produce results by returning a value

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

What is the adv and disadv of stack-dynamic variables?

A

adv: recursion + shared among subprograms
dis: time for allocation, initialization

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

What is the advantage of static local variables?

A

Opposite of stack-dynamic local variables

19
Q

What are the 3 modes for parameters?

A

In mode formal parameter: received data from an actual parameter
Out mode: Sends data to an actual parameter
Inout mode: Both

20
Q

What are the 2 ways data transfer can take place?

A

Physical copy of a value
Transmit access path to value

21
Q

What are the 5 implementation models for parameter passing?

A

pass-by-value
pass by result
pass by value result
pass by reference
pass by name

22
Q

What mode is pass by value?

A

In mode

23
Q

How does pass by value work?

A

The value of the actual parameter is used in formal parameter
Normally implemented by copying
can be done by transmitting an access path

24
Q

What mode is pass by result and how does it work?

A

Out mode
Value of formal parameter is used to change corresponding actual parameter

25
Q

What mode is pass by value result and how does it work

A

inout mode
Formal params have local storage

26
Q

How does pass by reference work and what mode is it?

A

Passes an access path (implemented using a reference or pointer) Inout Mode

27
Q

What mode is pass by name and how does it work?

A

Uses textual substitution
All formal parameter occurrences are replaced by the appropriate actual parameter

28
Q

What is parameter type checking?

A

Testing if the actual & formal parameter types match
(important for reliability)

29
Q

What must happen if multidimensional arrays are passe as parameters?

A

Compiler must map array subscript references to values
Mapping function must know size of all dimensions

30
Q

What are some design considerations for parameter passing?

A

Efficiency
1 way or 2 way data transfer

31
Q

How are c# method pointers declared?

A

deleates key word

32
Q

What are the 3 binding options?

A

Shallow binding (“Normal”)
Deep binding ( static scope)
Ad-hoc binding

33
Q

What is a overloaded subprogram?

A

Same as overloaded function

34
Q

What are the 2 types of subprograms?

A

Generic (template)
Polymorphic
(Take different parameter types in different calls)

35
Q

What is ad hoc polymorphism?

A

Overloaded subprograms

36
Q

When are subprogram versions created?

A

At compile time

37
Q

How is a wildcard represented and what does it mean in C++?

A

? it means any object

38
Q

How are side effects reduced?

A

Parameters should ideally be in mode.

39
Q

What is a closure?

A

An Anonymous function (function without name)

40
Q

What is a coroutine?

A

A subprogram with multiple entry points.

41
Q

What is a symmetric control

A

When the caller and called coroutines exist on a more equal basis.

42
Q

What is a coroutine call named?

A

A resume

43
Q

What is quasi-concurrent execution?

A

When a coroutine interleaves their execution but it doesnt overlap