PLC Session 3

In this session we talked about Names,Binding and Scopes. Our friend’s group was the one who did the presentation. It was an easy material because it’s what we , newbie coder already did and it was really easy to understand. Okay without further ado let’s talk about lesson on that day. This presentation divided into five topics as we can see it below

  • Introduction
  • Names
  • Variables
  • The Concept of Binding
  • Scope

The first topic is about introduction our friend’s group explained to us that imperative language are abstraction of von Neumann’s architecture that contains memory and processor. The abstractions in a language for the memory cells of the machine are variables. A variable can be characterized by a collection of properties, or attributes, the most important of which is type, a fundamental concept in programming languages. Designing the data types of a language requires that a variety of issues be considered.Among the most important of these issues are the scope and lifetime of variables. Now we go to the next topic that talked about Names, name is a string of characters used to identify some entity in a program. Basically names are the one that construct a variable, without a name variable can’t be built. In this topic our friend’s group explain the length of variable names that are allowed in languages like PHP, C++, C#, etc. We also learned that in PHP variable name must begin with dollar sign, variable in C-based languages are case sensitive, etc. Next topic is about variable, a program variable is an abstraction of a computer memory cell. A variable consist of Name, Address, Type, and value. Name is what we have discussed before, most variable needs name to be distinguished between variable. The address of a variable is the machine memory address with which it is associated. It is possible to have multiple variables that have the same address. When more than one variable name can be used to access the same memory location, the variables are called aliases.

The other component is Type, type of a variable determines the range of values the variable can store. When the value of a variable is the contents of the memory cell or cells associated with the variable. In the next topic we talked the concept of binding. A binding is an association between an attribute and an entity, such as between a variable and its type or value, or between an operation and a symbol. In this topic we learned that there are static type binding and dynamic type binding. A binding is static if it first occurs before run time begins and remains unchanged throughout program execution. Where which in Dynamic type binding, the type of a variable is not specified by a declaration statement, nor can it be determined by the spelling of its name. Instead, the variable is bound to a type when it is assigned a value in an assignment statement. When the type of a variable is statically bound, the name of the variable can be thought of being bound to a type, in the sense that the type and name of a variable are simultaneously bound. However, when a variable’s type is dynamically bound, its name can be thought of as being only temporarily bound to a type. In this topic we also learned about storage bindings and lifetime.The memory cell to which a variable is bound somehow must be taken from a pool of available memory. This process is what we as programmer called allocation. Whereas deallocation is the process of placing a memory cell that has been unbound from a variable back into the pool of available memory. We also learned that The lifetime of a variable is the time during which the variable is bound to a specific memory location. There are Static variables which are those that are bound to memory cells before program execution begins and remain bound to those same memory cells until program execution terminates. Whereas Stack-dynamic variables are those whose storage bindings are created when their declaration statements are elaborated, but whose types are statically bound. There are also Explicit Heap-Dynamic Variables and Implicit heap-dynamic variables.

The next topic is about scope, the scope of a variable is the range of statements in which the variable is visible. A variable is visible in a statement if it can be referenced in that statement. There are scope that are called static Scope, static scope was first introduced in ALGOL 60. Static scope is called static because the scope of a variable can be statically determined. Not to forget we also learned about blocks. There is also what we called global scope, Some languages, including C, C++, PHP, JavaScript, and Python, allow a program structure that is a sequence of function definitions, in which variable definitions can appear outside the functions. Definitions outside functions in a file create global variables, which potentially can be visible to those functions. Example of scope is shown below

function big() {
function sub1() {
var x = 7;
}
function sub2() {
var y = x;
var z = 3;
}
var x = 3;
}

The reference of x in sub2 in a static scope case will have the value of big’s x. Whereas in dynamic scope case,the x reference of x in sub2 will have the value of sub1’s x.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *