1/31
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Variables Definition
A placeholder for a value.
Can refer to complex types.
Generalized to include semantic concepts like closures.
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.
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.
Six Attributes of a Variable
Name
Address (L-Value)
Value (R-Value)
Type
Extent
Scope
Names (Identifiers) in Programming
Identify virtual entities in programs.
Design choices vary:
Case sensitivity
Length restrictions
Lexical rules
Clashes with reserved keywords.
Binding Definition
Static vs Dynamic Binding
Allocation and Deallocation
Extent Definition
Static Variables
Stack-Dynamic Variables
Explicit Heap-Dynamic Variables
Implicit Heap-Dynamic Variables
Static Type Binding - Type Declaration
Static Type Binding - Type Inference
Dynamic Type Binding
Extent for Different Variable Types
Scope Definition
Local Variables Scope
Static Variables Scope
Lexical Scope
Dynamic Scope Definition
Dynamic Scope Example (Perl)
local $x creates a dynamically scoped variable. ECMAScript Global Scope
Variables declared outside any function are globally scoped.
Accessible throughout the program.
ECMAScript Local Scope (Function)
Created by function parameters and variables inside functions.
Parameters and variables are local to that function.
ECMAScript No Block Scope (var)
No block scope exists with var.
Variables inside blocks are scoped to the containing function.
ECMAScript Object Properties
ECMAScript Closures
ECMAScript Prototype Chain
OCaml Scope - Function Parameters
OCaml Scope - Local Variables
Local variables are in scope only after the 'in' keyword.
Limited to the expression following it.
OCaml Scope - Recursive Bindings
let rec allows recursive references within its own definition.
Bound name is in scope before the 'in' keyword.