Variables

0.0(0)
Studied by 2 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/31

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 3:57 PM on 4/3/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

32 Terms

1
New cards

Variables Definition

  • A placeholder for a value.

  • Can refer to complex types.

  • Generalized to include semantic concepts like closures.

2
New cards

Variables and Memory Locations

  • Refer to explicit memory locations.

  • Some languages provide location info (e.g., &var in C).

  • Java's Unsafe class provides similar functionality.

3
New cards

Aliasing Definition

  • Occurs when two variables point to the same memory location.

  • Modifications through one alias affect the other.

  • Leads to confusing code and difficult bugs.

4
New cards

Six Attributes of a Variable

  • Name

  • Address (L-Value)

  • Value (R-Value)

  • Type

  • Extent

  • Scope

5
New cards

Names (Identifiers) in Programming

  • Identify virtual entities in programs.

  • Design choices vary:

    • Case sensitivity

    • Length restrictions

    • Lexical rules

    • Clashes with reserved keywords.

6
New cards

Binding Definition

  • Association between an entity and an attribute.
  • Determines connections between language elements and properties.
7
New cards

Static vs Dynamic Binding

  • Static binding occurs before execution and remains unchanged.
  • Dynamic binding occurs during execution and may change.
8
New cards

Allocation and Deallocation

  • Allocation: binding variable to an address.
  • Deallocation: unbinding variable from an address.
  • Can be static or dynamic.
9
New cards

Extent Definition

  • The time between allocation and deallocation.
  • Period during which a variable stores a meaningful value.
10
New cards

Static Variables

  • Bound to a memory location at initialization time.
  • Extent is the whole program execution.
11
New cards

Stack-Dynamic Variables

  • Allocated from runtime stack upon declaration.
  • Deallocated when procedure block returns.
12
New cards

Explicit Heap-Dynamic Variables

  • Allocated/deallocated by explicit runtime commands.
  • Examples: malloc/free in C, new/delete in C++, all objects in Java.
13
New cards

Implicit Heap-Dynamic Variables

  • Memory allocated with value assignments.
  • Deallocation occurs with reassignment.
14
New cards

Static Type Binding - Type Declaration

  • Variable introduced with explicit type and initial value.
  • Common in languages like Algol, C/C++, and Java.
15
New cards

Static Type Binding - Type Inference

  • No explicit variable types; inferred from usage.
  • Examples include various types in Fortran and Perl.
16
New cards

Dynamic Type Binding

  • Type binding at runtime based on assigned value.
  • Can change during execution.
17
New cards

Extent for Different Variable Types

  • Static: whole program execution.
  • Stack-dynamic: duration of procedure call.
  • Explicit heap-dynamic: explicit allocation/deallocation.
  • Implicit heap-dynamic: implicit allocation/deallocation.
18
New cards

Scope Definition

  • The part of code where a variable can be referenced.
  • Affects extent, impacting garbage collection.
19
New cards

Local Variables Scope

  • Declared within a program block.
  • Exist only within that block.
20
New cards

Static Variables Scope

  • Whole program scope.
  • Temporarily hidden by local variable name clashes.
21
New cards

Lexical Scope

  • Aligns scope to statically determined areas of source code.
  • Determined by program structure.
22
New cards

Dynamic Scope Definition

  • Determined at runtime based on control flow.
  • Use is uncommon in modern languages.
23
New cards

Dynamic Scope Example (Perl)

  • In Perl: local $x creates a dynamically scoped variable.
  • Access depends on call stack.
24
New cards

ECMAScript Global Scope

  • Variables declared outside any function are globally scoped.

  • Accessible throughout the program.

25
New cards

ECMAScript Local Scope (Function)

  • Created by function parameters and variables inside functions.

  • Parameters and variables are local to that function.

26
New cards

ECMAScript No Block Scope (var)

  • No block scope exists with var.

  • Variables inside blocks are scoped to the containing function.

27
New cards

ECMAScript Object Properties

  • Accessed via object instance.
  • Example: property attached to constructed object.
28
New cards

ECMAScript Closures

  • Function retains access to variables from the outer function's scope.
  • Inner function can access outer variables.
29
New cards

ECMAScript Prototype Chain

  • Properties on an object's prototype are accessible to instances.
  • Instance properties can override prototype properties.
30
New cards

OCaml Scope - Function Parameters

  • Function parameters are in scope throughout the function body.
  • From introduction until the end of function definition.
31
New cards

OCaml Scope - Local Variables

  • Local variables are in scope only after the 'in' keyword.

  • Limited to the expression following it.

32
New cards

OCaml Scope - Recursive Bindings

  • let rec allows recursive references within its own definition.

  • Bound name is in scope before the 'in' keyword.

Explore top notes

note
Music in the Fifteenth Century
Updated 1422d ago
0.0(0)
note
Spanish Final notes
Updated 1023d ago
0.0(0)
note
“OUTLINING”
Updated 1277d ago
0.0(0)
note
Syllabized IGCSE Biology
Updated 214d ago
0.0(0)
note
Music in the Fifteenth Century
Updated 1422d ago
0.0(0)
note
Spanish Final notes
Updated 1023d ago
0.0(0)
note
“OUTLINING”
Updated 1277d ago
0.0(0)
note
Syllabized IGCSE Biology
Updated 214d ago
0.0(0)

Explore top flashcards

flashcards
Waves Unit Terms
24
Updated 197d ago
0.0(0)
flashcards
Leyendas y Mitos
74
Updated 970d ago
0.0(0)
flashcards
(16) reproductive system
71
Updated 1229d ago
0.0(0)
flashcards
Contemporary Visual Arts
54
Updated 194d ago
0.0(0)
flashcards
6/6
53
Updated 298d ago
0.0(0)
flashcards
Latin Roots
115
Updated 1061d ago
0.0(0)
flashcards
Waves Unit Terms
24
Updated 197d ago
0.0(0)
flashcards
Leyendas y Mitos
74
Updated 970d ago
0.0(0)
flashcards
(16) reproductive system
71
Updated 1229d ago
0.0(0)
flashcards
Contemporary Visual Arts
54
Updated 194d ago
0.0(0)
flashcards
6/6
53
Updated 298d ago
0.0(0)
flashcards
Latin Roots
115
Updated 1061d ago
0.0(0)