opisdfjsfdajk Flashcards

1
Q

Definition of a Subprogram

A

Interface to and the actions of the subprogram abstraction

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

Subprograms in Major Languages

A

Executable: Python
Nonexecutable: Most other Languages
Ruby: Can be called without an object, like a function
Lua: anonymous

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

Subprogram call

A

Explicit request that the subprogram be executed

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

Parts of a subprogram

A

Header: First Part, includes name, kind of subprogram, and formal parameters

Profile (Signature): Number, order, types of its parameter

Protocol: Parameter profile and its functions, return type

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

Formal Parameter

A

Dummy variable listed in subprogram

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

Formal Parameters in Major Languages

A

C++, Python, Ruby PHP: can have default values

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

Categories of Subprograms

A

Procedure: Collection of statements that define parameterized computations

Functions: Resemble procedure but are modeled on math functions

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

Dynamic Stack Local Vars

A

ADV: Support for recursion; Storage for locals is shared among some subprograms

DIS: Allocation/Deallocation, initialization time, indirect addressing, Subprograms cannot be history-sensitive

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

Static Local Vars

A

ADV: Opposite of Stack Dynamic

DIS:

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

Static/Stack Dynamic in major languages

A

Stack Dynamic: Locals of most languages, Methods in Java, C++, Python, C#

Static: can be declared in C based languages

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

Semantic Models

A

In mode: actual –> formal
Out mode: formal –>actual
Inout Mode: actual <–> formal

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

Implementation Models

A

(Pass-by- )
value (In mode)
result (out mode)
value-result (inout mode)
reference (inout mode)
name (inout mode)

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

Parameter passing methods of major Languages

A

C: Pass by Value/reference
C++: Pass-by-reference
Java: (Non-object) Pass by value (objects) pass by reference
Fortran 95+: in, out, or inout mode
C#: Pass-by-value, reference can be called with ref
Python and Ruby: Pass by assignment

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

Type Checking

A

Non in Fortran and OG C
Required in Java and Pascal
Ansi C, C++ is a choice
Not required in Perl, Javascript, PHP
Not possible: Python Ruby

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

Shallow Binding

A

Environment of the call statement that enacts the passed subprogram

Dynamic-Scoping

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

Deep Binding

A

Enviorment of the definition of the passed subprogram

Static-Scoped

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

Types of Return Values in Major languages

A

C: allows any type except arrays and functions
C++: allows user-defined types
Java and C#: Can return any type
Python and Ruby: Can be returned

18
Q

Coroutines

A

Subprogram that has multiple entries and controls them itself
Coroutine call named resume, repeated resume eachother

19
Q

Overloaded subprogram

A

One that has the same name as another subprogram in same referencing enviroment

20
Q

Overloaded Subprograms in Major Languages

A

C++, Java, C#, ada: Predefined overloaded subprograms

21
Q

Overload in Java

A

Must differ in # of parameters, Data types, Sequence

Type Promotion:
Byte -> short->int->long->float->double

22
Q

Overload in Python

A

Every operator can be overloaded

23
Q

Subprogram Linkage

A

Subprogram call and return operations of a language are together

24
Q

Semantics of calls to a subprogram

A

Parameter passing methods
Stack-Dynamic allocation of local vars
Save the execution status of calling programs
Transfer of control and arrange for the return
If subprogram nesting is supported, access to nonlocal vars must be arranged

25
Q

General Semantics of subprogram returns

A

In, inout mode parameters must have their values returned
Deallocation of stack-dynamic locals
Restore the execution status
Return control to the caller

26
Q

Call Semantics

A

Save the execution status of caller
Pass the parameters
pass the return address to the called
Transfer control to the called

27
Q

Return Semantics

A

Pass-by-value/out mode parameters, move the value of those to their corresponding actual parameters

If function, move the functional value to a place the caller can reach

Restore the execution status of caller

Transfer control back to caller

28
Q

Activation Record

A

Format, or layout, of the non-code part

29
Q

Activation Record Instance

A

Concrete example of an activation record

30
Q

Revised Semantics Call

A

Caller Actions:
Create an ARI
Save the execution status of current program unit
Copute and pass the parameters
Pass the return address to be called
Transfer control to the called

Prologue actions of the called:
Save the old EP in the stack as the dynamic link and create the new value
Allocate local variables

31
Q

Dynamic Chain

A

Collection of dynamic links in the stack at a given time

32
Q

Local_offset

A

Local variable can be accessed by their offset from the beginning of the activiation record

33
Q

Nested Subprograms in Major Languages

A

Non-C-Based static-scoped languages use stack dynamic local variables and allow subprograms to be nested

34
Q

Locating a non local reference

A

Finding offset is easy
Finding the correct ARI

35
Q

Static chain

A

A chain of static links that connects certain ARI

36
Q

Static Link

A

an ARI for Subprogram A points to one of the ARIs of A static parents

37
Q

Static Depth

A

an integer associated with a static scope whose value is the depth of nesting of that scope

38
Q

Chain_offset or nesting_depth

A

Difference between the static_depth of the reference and what of the scope when it is decalred

39
Q

Deep access

A

Non local references are found by searching the ARIs on the dynamic chain

40
Q

Shallow Access

A

Put locals in a central place