Names, Scope & Bindings

High Level 

Abstracto

Machine Independence

Generaciones

3GL

Name, Scopes & Binding

Design L.P.

Name (Nombre)

  • En la mayoria alphanumericos
  • Simbolos tambien pueden ser nombres (+ :=)

Names

  • Variables
  • Constantes
  • Operaciones
  • Tipos
  • etc

Subrutinas

Abstracción de control

Clases

Abstracción de datos

Binding

Asociación entre 2 cosas

Name

lo que nombra

Biding Time

  • Language Design
  • Language Implementation
  • Program writing
  • Compile
  • Link
  • Load
  • Run

Ejemplos

Early Binding time vrs Later biding time

Ciclo de vida Objetos

Object timelife events

  • Creacion de los objetos
  • Creacion de los bidings
  • Rerefencias a las variables, subrutinas, types
  • Desactivacion y reactivacion de bidings
  • Destruccion de bidings
  • Destruccion de objetos

Punteros Repaso/Ejemplos

Binding Timelife

Object Timeline

No necesariamente ocurren al mismo tiempo

Dangling reference

#include <iostream>
using namespace std;
 
double & foo()
{
    double n = 12.4;
    double &ref = n;
    return ref;
}
 
double * foo2()
{
	double n = 12.4;
    double *ref = &n;
    return ref;
}
 
double foo3()
{
	double n = 12.4;
	return n;
}
 
int main()
{
	  double x = foo();
	  cout << x << endl;
 
	  double *y = foo2();
	  x = *y;
	  cout << x << endl;
 
	  x = foo3();
	  cout << x << endl;
 
	  return 0;
}

Object lifetime se rigen por 3 mecanismos de store allocation

  • Static
  • Stack
  • Heap

Static Allocation*

Static Allocation

  • Variables globales
  • Instrucciones de Translation (binary)
  • Literales
  • Compile Tables*
  • Subrutinas
  • Argumentos y return values
  • Temporales
  • Bookkepping information 

Llamados recursivos

Fortran

Literales y Constantes*

manifest constants o compile-time-constants.

Caso de Ada , C, C#

elaborate-time-constants

Stack-based Allocation

Stack-based Allocation

  • Cada instancia tiene su propio marco(frame) aka activation record*
  • Mecanismos de control del stack

Prologo

Epilogo

frame pointer

displacement addresing

Heap-based Allocation*

Se podria dar framentacion?

Garbage Colletion

Garbage Collection

  • Explicito*
  • Garbage Collector*

Memory Leak

Names, Scope & Bindings

By Mijail Paz

Names, Scope & Bindings

  • 600