





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






Spring 2003 CS 403 Class Notes (^) Page 1
Spring 2003 CS 403 Class Notes (^) Page 3
Based on program text
Spring 2003 CS 403 Class Notes (^) Page 7
Function Nesting in C(++)
C99 Nested Functions
Main
a
b c
Spring 2003 CS 403 Class Notes (^) Page 9
Static Scope with {}
Blocks - a method of creating static scopes inside program units--from ALGOL 60.
Examples: C and C++: for (...) {
Scope Nesting With {}
for (int i = 1; i <= 50; i++){ int x; x = 1;
for (int j = 1; j <= 50; j++){ cout << x << endl; //outer x x = j + 3; } }
Spring 2003 CS 403 Class Notes (^) Page 13
Static vs. Dynamic Scope: Behavior Differences
Static scope output: ?? Dynamic scope output: ??
Implementing Static Scope
Spring 2003 CS 403 Class Notes (^) Page 15
Example
Nesting Diagram
X dec
X dec
X dec
Use of x
Calling sequence
Run-Time Stack
Activation Records
Display
Reference to X in F1: (ND=1, offset= i )
Display(ND)+offset will yield address of X