Chapter 9 Flashcards

1
Q

Subprograms are process abstraction or data abstraction?

A

Process abstraction

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

What are the general characteristics of subprograms?

A

-Single entry point
-Caller is suspended until function returns
-Control always returns to the caller when finished

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

What are the basic definitions for subprograms?

A

definition - What the function does
call - Where the function is actually called
header - void function(parameter)

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

What are formal parameters?

A

Parameters in the subprogram header

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

What are actual parameters?

A

The parameters that are passed to the function call

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

What are positional parameters?

A

They bind formal parameters to their corresponding actual parameters via position

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

What are keyword parameters?

A

The name of a formal parameter with the actual parameter bound to it

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

How are positional/keyword parameters the same/different?

A

Both types bind formal and actual parameters. They differ by how they choose to bind them: position versus name

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

How do procedures and functions differ?

A

Functions are meant to return values, and procedures are meant to modify parameters

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

What are the design issues for subprograms?

A

-Choice of parameter passing methods
-Will parameters be type checked?
-Can subprogram definitions be nested?
-Can subprograms be overridden or generic?

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

What is a referencing environment?

A

A set of variables declared as local in a subprogram

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

What are the 3 parameter passing modes?

A

-In
-Out
-Inout

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

How are the parameter passing modes implemented?

A

-In: Pass-by-value
-Out: Pass-by-result
-Inout: Pass-by-value-result, pass-by-reference, pass-by-name

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

How do common languages support those parameter passing modes?

A

They use a runtime stack and copy/paste values to and from it

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

How are subprograms passed as parameters to subprograms?

A

-The environment of the call statement that enacts the passed subprogram (shallow binding)
-The environment of the definition of the passed subprogram (deep binding)
-The environment of the call statement that passed the subprogram as an actual parameter (ad hoc binding)

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

What is an overloaded subprogram?

A

A program with the same name as another program in the same reference space

17
Q

What is a generic subprogram?

A

Subprograms that can be reused

18
Q

What is a closure?

A

A subprogram and the referencing environment where it was defined

19
Q

What is a coroutine?

A

A special type of subprogram that runs alongside the program that called it