• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/56

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

56 Cards in this Set

  • Front
  • Back

Pass-by-Value

The local parameters are copies of the original arguments passed in




Changes made in the function to these variables do not affect originals




Advantage: fast for scalar; protection




Disadvantage: copy; additional memory

Pass-by-Reference

The local parameters are references to the storage locations of the original arguments passed in




Changes to these variables in the function will affect the originals




Advantage: no copy; no additional memory




Disadvantage: indirection; no protection

Pass-by-Value-Result

The actual parameter supplied by the caller is copied into the callee's formal parameter; the function is run; and the (possibly modified) formal parameter is then copied back to the caller.




Output is similar to Pass-by-Reference

Pass-by-Name

Re-evaluate the actual parameter on every use. For actual parameters that are simple variables, this is the same as pass-by-reference. For actual parameters that are expressions, the expression is re-evaluated on each access.




The local parameters are changed to the parameters passed in.

Static Dispatch

Method to invoke is decided at compile time




C++ uses this by defalt

Dynamic Dispatch

Selects which implementation of a polymorphic operation (method or function) to call at run time

Lexical Analysis

First step in compilation process




stream of characters => stream of words

Syntax Analysis

Second step in compilation process




stream of words => sentences (parse tree)

Semantic Analysis

Third step in compilation process




Checks if parse tree constructed follows the rules of the language

Optimization

Fourth step in compilation process




Transforms code to be more efficient

Code Generator

Fifth step in compilation process




Generates code

Formal Parameters

Refer to the variable as found in the function definition

Actual Parameters

Refer to the actual input passed

Named Static

Bound to memory cells before execution begins and remains bound to those same memory cells until it terminates




Example: C (global variables)

Stack Dynamic

Bindings created when declaration statements are elaborated




Example: C++

Explicit Heap-Dynamic

Nameless memory cells are allocated and deallocated by explicit run-time instructions by the programmer




Example: Java (new)

Implicit Heap-Dynamic

Bound to heap storage only when they are assigned values




Example: JavaScript

Static-Scoping Rules

The scope is determined prior to execution

It's possible to determine the scope of a declaration by looking only at the program (compile time)

Dynamic-Scoping Rules

Each identifier has a global stack of bindings and it only exists at run-time




It's based on the calling sequence of subprograms

Six Main Attributes of a Variable

Name


Address


Type


Value


Binding/Lifetime


Scope

Name

A string of characters used to identify some entity in a program

Reserved Word

A name that cannot be used as used defined name

Keyword

A name that is part of a language construct but can be used as a used defined name

Address

The machine memory address with which it's associated with

Type

Indicates a variable's range of values it can take and the applicable operations

Binding

Associates an attribute and an entity

Binding Time

The time at which the binding takes place

Static Binding

It occurs before the execution begins and doesn't change during execution

Dynamic Binding

It's created during execution or it can change during execution

Static Typing

Explicit: A statement in a program that lists variable names and specifies that they are a particular type


Example - Java




Implicit: A means of associating variables with types through default conventions, rather than declaration statements


Example - OCaml

Dynamic Typing

The variable is bound to a type when it's assigned a value in an assignment statement. When the assignment statement is executed, the variable being assigned is bound to the type of the value of the expression on the right side of the assignment



Example: Scheme

Allocation

Creates a binding between a variable and memory cells in an available memory pool

Desallocation

Removes the binding and puts the memory cells back in the available memory pool

Lifetime

The time during which a variable is bound to a specific memory cell

Scope

Range of statements in which the variable is visible, i.e. in which it can be referenced or assigned

Local Variable

In a program unit if the variable has been declared in this unit

Referencing Environment

The collection of all variables that are visible in the statement




In a static-scoped language it's the variables declared in its local scope plus the collection of all variables of its ancestor scopes that are visible

Named Construct

A variable that is bound to a value only once.




Useful as aids to readability and program reliability; parameterizes a pgram

Data Type

Defines a collection of data values and a set of predefined operations on those values

Primitive Data Types

Data types that are not defined in terms of other types

Design Issues of Character String Types

Should strings be a special kind of character array or a primitive type?




Should strings have static or dynamic length?

Design Issues of Enumeration Types

Is an enumeration constant allowed to appear in more than one type of definition, and if so, how is the type of an occurrence of that constant in the program checked?




Are enumeration values coerced to integer?




Are any other types coerced to an enumeration type?

Design Issues of Array Types

What types are legal for subscripts?




Are subscripting expressions in element references range checked?




When are subscript ranges bound?




When does array allocation take place?




Are ragged or rectangular multidimensioned arrays allowed, or both?




Can arrays be initialized when they have their storage allocated?




What kinds of slices are allowed, if any?

Static Array

An array in which the subscript ranges are statically bound and storage allocation is static (done before run time)




Advantage: efficiency




Disadvantage: storage is fixed for the entire execution time of the program

Fixed Stack-Dynamic Array

An array where the subscript ranges are statically bound, but the allocation is done at declaration elaboration time during execution




Advantage: Space efficiency




Disadvantage: required allocation and deallocation time

Fixed Heap-Dynamic Array

Similar to a fixed stack-dynamic array but different in that both the subscript ranges and storage bindings are done when the user program requests them during execution, and the storage is allocated from the heap




Advantage: flexibility




Disadvantage: allocation time from the heap

Heap-Dynamic Array

An array where the binding of subscript ranges and storage allocation is dynamic and can change any number of times during the array's lifetime




Advantage: flexibility




Disadvantage: allocation and deallocation take longer and my happen many times during execution of the program

Rectangular Array

A multidimensional array where all the rows have the same number of elements and all of the columns have the same number of elements

Jagged Array

An array where the lengths of the rows don't need to be the same

Design Issues of Record Types

What is the syntactic form of references to fields?




Are elliptical references allowed?

Design Issues of Pointer Types

What are the scope and lifetime of a pointer variable?




What is the lifetime of a heap-dynamic variable (the value a pointer references)?




Are pointers restricted as to the type of value to which they can point?




Are pointers used for dynamic storage management, indirect addressing, or both?




Should the language support pointer types, reference types, or both?

Fortran I

Created by IBM




Imperative, strongly related to hardware




Variables up to 6 characters




Subprogram (non-recursive), conditional, loop




Implicit typing based on the name of the variable

Design Issues for Subprograms

Are local variables statically or dynamically allocated?




Can subprogram definitions appear in other subprogram definitions?




What parameter-passing methods are used?




Are the types of the actual parameters checked against the types of the formal parameters?




Can subprograms be generic?

Diamond Inheritance

An ambiguity that arises when two classes B and C inherit from A, and class D inherits from both B and C. If there is a method in A that B and C have overridden, and D does not override it, then it's unknown if the version D inherits is from B or C

Single Inheritance

At most one direct parent per class




Languages: Java

Multiple Inheritance

Possibly more than one parent class




Languages: C++