Docsity

Programming Lang. Cumulative Review | CS 3723 - Programming Languages, Quizzes of Programming Languages

Toggle sidebar
bg1
TERM 1
A functional programming paradigm:
DEFINITION 1
Lisp
TERM 2
An imperative programming paradigm:
DEFINITION 2
C
TERM 3
An object-oriented programming paradigm:
DEFINITION 3
C++Java
TERM 4
One advantage of using compilation to
implement a programming language is...
DEFINITION 4
Code optimization
TERM 5
One advantage of using interpretation to
implement a programming language is...
DEFINITION 5
dynamically modify code
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe

Partial preview of the text

Download Programming Lang. Cumulative Review | CS 3723 - Programming Languages and more Quizzes Programming Languages in PDF only on Docsity!

A functional programming paradigm:

Lisp TERM 2

An imperative programming paradigm:

DEFINITION 2 C TERM 3

An object-oriented programming paradigm:

DEFINITION 3 C++Java TERM 4

One advantage of using compilation to

implement a programming language is...

DEFINITION 4 Code optimization TERM 5

One advantage of using interpretation to

implement a programming language is...

DEFINITION 5 dynamically modify code

Advantage of high-level programming

languages

Programmer efficiency TERM 7

Turing complete languages can express all

____________ functions.

DEFINITION 7 partial recursive TERM 8

The difference between and expression and a

statement:

DEFINITION 8 Expression returns a value (eg: x + y returns z)Statement is imperative (do x) TERM 9

A language treats functions as first class

objects if...

DEFINITION 9 functions can do everything a regular object can do:pass functions as argumentsreturn functionsassign variables to functions TERM 10

Lisp/Scheme lists are different than ML lists

because

DEFINITION 10 ML lists can only take one variable typeLisp/Scheme can take multiple types in a list

A lambda calculus expression is in the normal

form if

cannot be reduced further TERM 17

Lambda calculus is said to be confluent

because...

DEFINITION 17 If a lambda calc expression has a normal form, the normal form is unique. TERM 18

Each type is a collection of values that...

DEFINITION 18 share structural properties TERM 19

Types can be used to organize different

concepts of the problem domain, to (1)__ and

to (2)__.

DEFINITION 19

  1. TO DO...2) make efficient translation TERM 20

Structural Equivalence

DEFINITION 20 Two types are equivalent ifa) they share the same basic type orb) they are built using the same compound constructor w/ same components

Name Equivalence

Equivalent if two types share the same name TERM 22

Type Error

DEFINITION 22 Type errors occur when a type is misused or misinterpreted TERM 23

Type Safe

Language

DEFINITION 23 A lang that does not allow unchecked type errors at runtime. TERM 24

Name a type safe language:

DEFINITION 24 Java TERM 25

Name a type unsafe language:

DEFINITION 25 C, C++

Program Pointer (in runtime machine model

of compiled language)

Points to next instruction to be evaluated TERM 32

Runtime Stack (in runtime machine model of

compiled language)

DEFINITION 32 Map variables to their values TERM 33

Heap (in runtime machine model of compiled

language)

DEFINITION 33 dynamically allocated storage TERM 34

Environment Pointer (in runtime machine

model of compiled language)

DEFINITION 34 current stack positionkeeps track of storage of all active variables TERM 35

Types of Parameter Passing

DEFINITION 35 Pass-by-valuePass-by-referencePass-by-name

When a function is returned as a result, __

must be saved in the heap as part of the f.

closure.

non-local variables accessed by function saved in the heap so that when the environment of function (activation record that defines function) is popped off the stack those variables remain valid when function is eventually called TERM 37

Continuation

DEFINITION 37 "The remaining work to be done after evaluating the expression" TERM 38

Continuation implemented as a function

closure does what?

DEFINITION 38 does not return to callercalls next portion of code TERM 39

Exception is a language support for programs

to:

DEFINITION 39 Jump out of blocks TERM 40

To support exceptions, a language must (1)_,

(2), (3)

DEFINITION 40

  1. support declaration of different types of exceptions2) a special operator which can be invoked to raise an exception3) declaration of handlers for different types of exceptions

Function Closure

The value of a function definition which contains the address of the function body and the environment (activation record) where the function is defined) TERM 47

Tail-recursive Call

DEFINITION 47 No more computation is done after the call TERM 48

Why are tail recursive calls equiv. to loops?

DEFINITION 48 No operation is required after the recursive function call, the activation record of the caller can be popped off the stack before making the recursive call; that is, the callee can reuse/modify the activation record of the caller. TERM 49

When looking for exception handlers, ____

scoping is used.

DEFINITION 49 dynamic TERM 50

The type of the values returned by the

exception handler must match the return

type of ____.

DEFINITION 50 function handling the exception

How are symbolic names in a Java class

resolved?

Each name is only resolved if/when it is used in a instruction being interpreted by the JVM. TERM 52

Method calls: class obj vs. interface obj

DEFINITION 52 The method may reside in different vtable entries if from an interface obj, but always at the same location if from a class obj. TERM 53

List challenges of supporting multiple

inheritance in a C++/Java class object.

DEFINITION 53

  1. A separate view must be created for each base class, and the object address may need to be changed when casting it to a base class type2) The starting location of this thispointer needs to be saved for each virtual method implementation.3) The compiler must resolve naming conflicts from diff. base classes TERM 54

List type errors that cannot be caught at

compile time.

DEFINITION 54 array out-of-bounds accessdereferencing a pointer that has already been freedcasting a base type to the wrong derived type (subtype) TERM 55

Polymorphism

DEFINITION 55 In computer science, polymorphism is a programming language feature that allows values of different data types to be handled using a uniform interface.

Contents of Runtime Machine Model of a

Compiled Program

Code space: contains all instructions of program to be evaluatedProgram pointer: points to the current instr. being evaluatedRuntime stack: contains the vals for all vars in the programEnvironment pointer: points of the top of the runtime stackHeap: contains dynamically allocated storage TERM 62

Runtime Machine of Compiled Prog compared

to Scheme Abs. Machine

DEFINITION 62 code space = continuationprogram pointer = current expressionruntime stack = A-listenvironment pointer = A- listheap = cons cells TERM 63

Control Link (in Activation Record)

DEFINITION 63 Points to the calling block TERM 64

Access Link (in Activation Record)

DEFINITION 64 Points to defining block of this block TERM 65

Return Address (in Activation Record)

DEFINITION 65 Only in function blocksPoints to where computation continues after function return if tail recursive, points to line following call if not tail recursive, point to calling line

Return Result Address (in Activation Record)

Only in function blockspoints to tmp value in calling block