The concepts of binding and object lifetime in programming languages. It covers the different binding times, static vs dynamic binding, and the impact on efficiency and flexibility. Additionally, it explains the role of object lifetime in storage management and the difference between static, stack, and heap allocation.
Download Binding and Object Lifetime in Programming Languages and more Study notes Programming Languages in PDF only on Docsity!
1
Programming Languages
Tevfik Koşar
Lecture - VII February 7th, 2006
2
Roadmap
Names
Scopes
Binding
Binding Times
Static vs Dynamic Binding
Object Lifetime & Storage Management
3
Name, Scope, and Binding
A name is exactly what you think it is
Most names are identifiers
Constants, variables, functions
symbols (like '+') can also be names
A binding is an association between two things,
such as a name and the thing it names
The scope of a binding is the part of the
program (textually)in which the binding is
active
4
Binding Time
Binding Time is the point at which a binding is
created or, more generally, the point at which
any implementation decision is made
language design time
program structure, control flow, possible types
language implementation time
Coupling of I/O to OS
arithmetic overflow
Maximum sizes of stack and heap
Precision of the (number of bits) of fundamental types
7
Static vs Dynamic Binding
The terms STATIC and DYNAMIC are generally
used to refer to things bound before run time
and at run time, respectively
“static” binding before run time
"dynamic“ binding at run time
8
Binding
In general, early binding times are associated
with greater efficiency
Later binding times are associated with greater
flexibility
Compiled languages tend to have early binding
times
Interpreted languages tend to have later
binding times
9
Object Lifetime
Key events
creation of objects
creation of bindings
references to variables (which use bindings)
(temporary) deactivation of bindings
reactivation of bindings
destruction of bindings
destruction of objects
10
Object Lifetime
The period of time from creation to destruction is called the LIFETIME of a binding - If object outlives binding it's garbage - If binding outlives object it's a dangling reference
The textual region of the program in which the binding is active is its scope
In addition to talking about the scope of a binding, we sometimes use the word scope as a noun all by itself, without an indirect object