Name, binding, and scope

BAB III
Names, Binding and Scopes
Imperative programming languages are, to varying degrees, abstractions of the underlying von Neumann computer architecture.
Imperative languages are abstractions of von Neumann architecture
–        Memory
–        Processor
The abstraction in language for the memory cells are variables. Among the most important of these issues are the scope and lifetime of variables. Functional programming languages allow expressions to be named.
Variables are characterized by attributes
–        To design a type, must consider scope, lifetime, type checking, initialization, and type compatibility.
Names: a string of characters used to identify some entity in a program.
·         Length if too short, they cannot be connotative.
·         Special characters, in some programming language require naming using a special character like $ or @.
·         Case sensitivity different kind of case different names. For example, “Device” and “device” is a different name
Variables
Variable is an abstraction of memory cell. Variable is not only a name for a memory cell, what it does is replacing an absolute memory cell with a name.
Variables can be characterized as a sextuple of attributes
1.       Name = the name of the variable to be called when needed
2.       Address = where the variable located in the memory
3.       Value = what the variable has stored.
4.       Type = variable has their own type depending on what we need.
5.       Lifetime
a.       Static--bound to memory cells before execution begins and remains bound to the same memory cell throughout execution
b.       Stack-dynamic--Storage bindings are created for variables when their declaration statements are elaborated.
c.       Explicit heap-dynamic -- Allocated and deallocated by explicit directives, specified by the programmer, which take effect during execution
d.       Implicit heap-dynamic--Allocation and deallocation caused by assignment statements all variables in APL; all strings and arrays in Perl, JavaScript, and PHP
6.       Scope = The scope of a variable is the range of statements over which it is visible
a.       Global Scope where the variable is visible to every unit in a program
b.       Static Scope finding the nearest declaration of the variable
c.       Dynamic Scope based on stack-call.
The Concept of Binding
A binding is an association between an entity and an attribute, such as between a variable and its type or value, or between an operation and a symbol
Binding time is the time at which a binding takes place. 

Tidak ada komentar:

Posting Komentar