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

A

Copy

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
Q

What are the cons for pass by value, pass by result and pass by value-result

A

Parameter collision for the result ones
Extra storage
Copy and storage can be costly if large

26
Q

What is pass by value result and what are the two steps

A

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
Q

Pass by reference is an implementation model for

A

Inout mode params

28
Q

Most languages use what type of stack to pass parameters

A

runtime

29
Q

When are inmode parameters used

A

Whenever no data is returned to the caller

30
Q

When is outmode parameters used

A

When no data is transferred to the callee but the sub routine but transmit data back to the caller

31
Q

When is inout mode params used

A

Used only when data must move in both directions between caller and caller

32
Q

What are two complications with subroutine params

A

Are params type checked

What ref envi should be used for executing the passed subroutine

33
Q

Shallow binding is the environment of the call statement that

A

Enacts the passed subroutine

34
Q

Deep binding is the environment of the

A

Definition of the subroutine

35
Q

Ad hoc binding is the environment of the call statement that

A

Passed it as an actual parameter

36
Q

When can deep binding and ad hoc brining be the same

A

When a subroutine is declared and passed by the same subroutine

37
Q

Static scoped languages usually use what type of being gay

A

Deep

38
Q

Dynamic scoped languages usually used what type of binding

A

Shallow

39
Q

What is an overloaded subroutine

A

Has same name as another subroutine but different referencing environment but different signature

40
Q

What is an generic/polymorphic subroutine

A

Takes parameters of different types on different activations

41
Q

Ad hoc polymorphism is what type of subroutines

A

Overloaded subroutines that need not behave similarly

42
Q

What type of polymorphism is provided by a subroutine that takes generic params to describe the types of params

A

Parametric

Often called generic subroutines

43
Q

What is a subroutine that has multiple entry points which are controlled by these particular types of subroutines themselves

A

Coroutine

44
Q

What is the invocation of a coroutine named

A

Resume