Names - Binding - Type Checking - Scopes

2020-07-23 |
  • Names are identifiers. In early years these identifiers are very restirected like single character names.
  • Case sensitive programming languages: Camel case, Kebab case
  • Can be think as a memory locations
  • Type: set of values with operations
  • Value: belleğin içerisinde bulunan değer. lvalue ==> address, rvalue ==> bellekte bulunan değer

Binding

int myVar;
myVar = abs(myVar * -2);
  • Some bindings can be different times.
  • For example:
    • Compile time
    • Load time
    • Run time
    • Link time

Static

  • Before run time

Dynamic

  • In run time binding

Type Binding

  • Each variable has a unique memory location.
  • And it can be different memory sizes. We need to know type size to create memory location.
  • (Static Type Binding) Explicit type: int x; this is static.
    • Strong type checking
  • (Dynamic Type Binding) Implicit type: var = 5 python. this dynamic
    • We need to create dynamic storage binding for that
    • Because we don't know exact memory location has a enough memory size

Storage Binding

  • Memory is located to specific memory location
  • Variables can be dead during in program: life time of var

Type of Variables

  • Static Variable: life time ==> entire program
  • Stack Dynamic: When programs enter specific scope it will allocate it's own memory location.
  • Explicit Heap Dynamic: Uses heap section of the memory. When using new malloc etc.
    • Garbage collector search for memory explicit heap
  • Implicit Heap Dynamic: Uses heap section of the memory. Example python x=3; x="hello" bellek yetmediği zaman bunun için dynamic olarak bi bellek bölgesi alınıyor.

Type Checking

Example:

x && y 
  • x and y need to be boolean operators.
  • function parameters
  • compatibility: integer will be compatible with integer. also it can be more flexible.

Name equaivalence

  • pure none equaivalence:
  • transitive none equaivalence: typedef we just give another

Structural Type Compability

  • Tüm elemanların compatible olması lazım

Scope

  • Each variable has a lifetime
  • Local variables are bound between { }
  • For non-local references we have two options.

Static Scoping

  • Compiler search in nested hiearchy
  • We can think scopes as a tree
  • If we want to search for a variables we need to search for scopes
  • First search in it's own scope
  • After go to static parent
  • Scope resolution

Dynamic Scoping

  • Nereden çağırıldıysa oradaki local değişkenleri referansları alabiliriz


This was the end of the blog post. You can reach me via email umusasadik at gmail com