Chapter 9 Flashcards

(43 cards)

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?

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
What mode is pass by value result and how does it work
inout mode Formal params have local storage
26
How does pass by reference work and what mode is it?
Passes an access path (implemented using a reference or pointer) Inout Mode
27
What mode is pass by name and how does it work?
Uses textual substitution All formal parameter occurrences are replaced by the appropriate actual parameter
28
What is parameter type checking?
Testing if the actual & formal parameter types match (important for reliability)
29
What must happen if multidimensional arrays are passe as parameters?
Compiler must map array subscript references to values Mapping function must know size of all dimensions
30
What are some design considerations for parameter passing?
Efficiency 1 way or 2 way data transfer
31
How are c# method pointers declared?
deleates key word
32
What are the 3 binding options?
Shallow binding ("Normal") Deep binding ( static scope) Ad-hoc binding
33
What is a overloaded subprogram?
Same as overloaded function
34
What are the 2 types of subprograms?
Generic (template) Polymorphic (Take different parameter types in different calls)
35
What is ad hoc polymorphism?
Overloaded subprograms
36
When are subprogram versions created?
At compile time
37
How is a wildcard represented and what does it mean in C++?
? it means any object
38
How are side effects reduced?
Parameters should ideally be in mode.
39
What is a closure?
An Anonymous function (function without name)
40
What is a coroutine?
A subprogram with multiple entry points.
41
What is a symmetric control
When the caller and called coroutines exist on a more equal basis.
42
What is a coroutine call named?
A resume
43
What is quasi-concurrent execution?
When a coroutine interleaves their execution but it doesnt overlap