PL Chapter 4 Part 1
PL Chapter 4 Part 1
Scopes
Programming Languages
Chapter 4 Part 1
Introduction
Imperative PLs are, to varying degrees, abstractions of
the underlying von Neumann computer architecture.
The architecture’s two primary components are its
name.
same address.
When more than one variable name can be used to
Name
Address
Type
Representation (value
Scope
Lifetime
entities:
• Name and memory location (for variables)
• Name and function
Typically a binding is between a name and
the object it refers to.
The scope of a binding is the region of a
Early binding
• Faster code
• Typical in compiled languages
Late binding
• Greater flexibility
• Typical in interpreted languages
Object lifetime
• Period between the creation and destruction of the object
• Example: time between creation and destruction of a
dynamically allocated variable in C++ using new and
delete
Binding lifetime
• Period between the creation and destruction of the
binding (name-to-object association)