Subprograms Flashcards

1
Q

Subroutines are the

A

Fundamental building blocks of programs

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

Where can subroutines be defined?

A

Within programs or separately in libraries

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

What are some other names for a subroutine are (4)

A

Procedure, routine, method or subprogram

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

During the execution of a subroutine the caller is

A

Suspended

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

Where is the control returned to when a subroutine execution terminates

A

To the caller

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

Parameters/formal params are the

A

Expected values

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

Actual pamareter/arguments are the

A

Actual values provided by the calling program

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

What are the two types of actual/formal parameters

A

Positional and keyword parameters

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

Position parameters the binding is done

A

By the position

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

Keywords parameters, what are stored together

A

Formal parameters and corresponding actual parameters

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

What are the advantages of network parameters

A

Order is irrelevant

Don’t worry about wrongly ordered parameters

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

Disadvantages keyword parameters

A

Users must know and specify the names of formal parameters

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

What are the two parameters passing methods

A

Semantic models and implementation models

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

What are the three distinct semantic models that formal parameters are characterized by?

A

In mode, out mode, and inout mode

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

What is inmode?

A

They can receive data from the corresponding actual parameters

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

What is out mode?

A

They can transmit data to the actual parameters

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

Inout mode

A

Inmode and out mode

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

What are the five implementation models?

A

Pass by value, pass by result, pass by value result, pass by reference and pass by name

19
Q

What is pass by value

A

The value of the actual parameter is used to initialize the corresponding formal parameters which then acts as a local variable in the subprogram.

20
Q

What do pass by value used to implement

A

In-mode semantics

21
Q

What are Pass by value implemented by

22
Q

What is Pass by result

A

No value is transmites to a subroutine
The corresponding formal parameter acts as a local variables whose value is transmitted back to the callers actual parameter

23
Q

What as pass by result used to implement

A

Out-mode params

24
Q

What are the pros for pas any result and pass by value?

A

Fast for scalars (linkage costs and access time)

No side affects to the params

25
What are the cons for pass by value, pass by result and pass by value-result
Parameter collision for the result ones Extra storage Copy and storage can be costly if large
26
What is pass by value result and what are the two steps
Combo of pass by value and pass by result (pass by copy) (1) value of the actual parameter is used to initialize the corresponding formal param (2) the formal parameters acts as a local variables and at sub termination value is transmitted back to the actual parameter
27
Pass by reference is an implementation model for
Inout mode params
28
Most languages use what type of stack to pass parameters
runtime
29
When are inmode parameters used
Whenever no data is returned to the caller
30
When is outmode parameters used
When no data is transferred to the callee but the sub routine but transmit data back to the caller
31
When is inout mode params used
Used only when data must move in both directions between caller and caller
32
What are two complications with subroutine params
Are params type checked | What ref envi should be used for executing the passed subroutine
33
Shallow binding is the environment of the call statement that
Enacts the passed subroutine
34
Deep binding is the environment of the
Definition of the subroutine
35
Ad hoc binding is the environment of the call statement that
Passed it as an actual parameter
36
When can deep binding and ad hoc brining be the same
When a subroutine is declared and passed by the same subroutine
37
Static scoped languages usually use what type of being gay
Deep
38
Dynamic scoped languages usually used what type of binding
Shallow
39
What is an overloaded subroutine
Has same name as another subroutine but different referencing environment but different signature
40
What is an generic/polymorphic subroutine
Takes parameters of different types on different activations
41
Ad hoc polymorphism is what type of subroutines
Overloaded subroutines that need not behave similarly
42
What type of polymorphism is provided by a subroutine that takes generic params to describe the types of params
Parametric Often called generic subroutines
43
What is a subroutine that has multiple entry points which are controlled by these particular types of subroutines themselves
Coroutine
44
What is the invocation of a coroutine named
Resume