Columbia COMS W4115 - Names, Scope, and Bindings (71 pages)

Previewing pages 1, 2, 3, 4, 5, 33, 34, 35, 36, 67, 68, 69, 70, 71 of 71 page document View the full content.
View Full Document

Names, Scope, and Bindings



Previewing pages 1, 2, 3, 4, 5, 33, 34, 35, 36, 67, 68, 69, 70, 71 of actual document.

View the full content.
View Full Document
View Full Document

Names, Scope, and Bindings

67 views


Pages:
71
School:
Columbia University
Course:
Coms W4115 - Programming Languages and Translators
Programming Languages and Translators Documents

Unformatted text preview:

Names Scope and Bindings COMS W4115 Prof Stephen A Edwards Spring 2003 Columbia University Department of Computer Science What s In a Name Name way to refer to something else variables functions namespaces objects types if a 3 int bar baz a 2 int a 10 Names Objects and Bindings binding Object4 Name1 Object3 Name2 ing d bin Object1 Object2 g n i Name3 nd bi b Name4 g indin Names Objects and Bindings binding Object4 Name1 Object3 Name2 g din g bin in ind b Object1 Object2 Name3 Name4 g indin b When are objects created and destroyed When are names created and destroyed When are bindings created and destroyed Object Lifetimes When are objects created and destroyed Object Lifetimes The objects considered here are regions in memory Three principal storage allocation mechanisms 1 Static Objects created when program is compliled persists throughout run 2 Stack Objects created destroyed in last in first out order Usually associated with function calls 3 Heap Objects created deleted in any order possibly with automatic garbage collection Static Objects class Example public static final int a 3 public void hello System out println Hello Static class variable Code for hello method String constant hello Information about Example class Static Objects Advantages Zero cost memory management Often faster access address a constant No out of memory danger Disadvantages Size and number must be known beforehand Wasteful if sharing is possible Stack Allocated Objects Natural for supporting recursion Idea some objects persist from when a procedure is called to when it returns Naturally implemented with a stack linear array of memory that grows and shrinks at only one boundary Each invocation of a procedure gets its own frame activation record where it stores its own local variables and bookkeeping information Activation Records argument 2 argument 1 return address frame pointer old frame pointer local variables temporaries arguments stack pointer growth of stack Activation Records Return



View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...
Login

Join to view Names, Scope, and Bindings and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Names, Scope, and Bindings and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?