CS 342 Lecture -*- Outline -*- * environments and scope of declarations (contexts) how do we know what the assignment "I = 27" means? have to know what I means, from its declaration (real vs. int) what is the meaning of the declaration "INTEGER I"? establishes binding of I to an integer cell ** Environment mapping from identifiers to attributes (such as type, storage) (like symbol table discussed earlier) different environments in different parts of a program ------------------- PROGRAM MAIN INTEGER N ... CALL Q(N,3) ... END SUBROUTINE Q(M,L) REAL X ... END ------------------- ** Visibility a *declaration* is visible if present in active environment -loosely, an identifier is visible if the current environment has some binding for that name ** Scope (of a declaration) area of program text where a declaration is visible show *contour diagram* for example subprogram arguments and variables *local* in FORTRAN (good because these details should be hidden from clients) scope of subprogram names is entire program, *global* ** Contour diagrams Show visibility of declarations (i.e., scope) (can see out but not into box)