Sep 19, 2003 ------------- - Continuation of scoping - Notion of a "block-structured" language - block: a group of statements w/ their own declarations (scope) - Advantages of static scoping - readability - predictability - type checking/validation - Some aspects of dynamic scoping - flexibility - sometimes makes things easy - (e.g., no need to pass params if they are present in an outer scope) - difficult to debug - no locality of access - can have unintended consequences - What does "static" mean in C? - the variable is bound statically to a location and doesn't change during run-time - but its lifetime is dynamic! - simple usage: a function that returns the # times it is called - Notion of referencing environment - set of variables that are visible at any given point in the program - worked out examples from book - How memory is allocated - two "areas" moving toward each other - stack: for runtime use under control of system - heap: legalized mess, for use by programmer - Some problems you will run into, during memory tinkering - garbage - dangling references (e.g., 404 in HTTP) - aliases - - Chapter 6: types - what is a type? - primitive and constructed types