NAMES, BINDING, AND SCOPES

NAMES, BINDING, AND SCOPES

Variables is an abstraction of a memory cell. Variable provide a way of labeling data with a descriptive name, so the program can be understood more clearly by the reader. To design it, we must consider scope, lifetime , type checking, initialization, and type compatibility.

Name in programming language is a string of character that used to identify a program. If too short, they cannot be connotative. Every language can have different maximum character of name. for example  FORTRAN 95 has maximum 31 character but C++ has no limit.

There are special characters to variable names, for example PHP variable names must begin with dollar signs and in Ruby variables names begin with @. Special character specify the variable’s type.

Variable names are case sensitive in some language. The disadvantage is readability, because name that look alike ex(name and Name) is different.

The Concept  of Binding

Binding is association between an entity and an attribute, for ex, between operation and symbol.

Binding time is the time which a binding takes place.

Possibility binding times; language design time, language implementation time, compile time, load time, runtime.

Dynamic Type Binding, it can change after runtime when the program run.

Scope refers to the visibility of variables and methods in one part of a program to another part of that program. There are two general scope concepts in most language : local and global scope.

Block is method to creat static scope in program unit.

Ex:

{

Int temp;

Temp=list[upper];

list[upper]= list[lower];

list[lower]=temp;

}

Local scope, variables or methods that have local scope are accessible only in the current block of code.

Global scope, all of the variables defined at the beginning of a program are available to the entire program. In a function, the variables that declared at the beginning are available to all code in that function.

 

 

 

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

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