Visibility and Symbol Tables




CS152

Chris Pollett

Mar. 4, 2009

Outline

Introduction

Visibility

More on Visibility

The Symbol Table

Example Program to Illustrate Symbol Table

int x;
char y; // (*)
void p() {
   double x;
   ... // (**)
   { int y[10]; // (***)
   }
} // (****)
void q() { int y; /* (#) */} // (##)
int main() {char x; /* (###) */}

Symbol Table Example

More Symbol Table Example

Static Versus Dynamic Scoping

Example Program to Illustrate Dynamic Scoping

#include <stdio.h>
int x = 1;
char y = 'a';
void p() { double x = 2.5;
    printf("%c\n", y); // (***)
    {
        int y[10];
    }
}
void q() { int y = 42;
    printf("%d\n", x); //(**)
    p();
}
int main() { char x= 'b'; // (*)
   q();
   return 0;
}

More Dynamic Scoping Example

Yet More Dynamic Scoping Example