{ File: comptipi.pas }

{ Scopo: illustrare il meccanismo di compatibilita` tra variabili in PASCAL }

program CompatibilitaTraTipi;

type
  T1 = array [1..10] of integer;
  T2 = T1;
  T3 = array [1..10] of integer;

var
  a1, a2 : T1;       { a1 e a2 hanno lo stesso tipo T1 }
  a3     : T1;       { a3 ha lo stesso tipo T1 di a1 e a2 }
  a4     : T2;       { a4 ha lo stesso tipo T1 = T2 di a1, a2 e a3 }

  b1, b2 : T3;       { b1 e b2 hanno lo stesso tipo T3,
                       ma tipo diverso da a1, a2, a3 e a4 }

  c1, c2 : array [1..10] of integer;
                     { c1 e c2 hanno lo stesso tipo array [1..10] of integer,
                       ma tipo diverso da a1, a2, a3, a4, b1, b2 }

  d1, d2 : array [1..10] of integer;
                     { d1 e d2 hanno tipo array [1..10] of integer, ma sono
                       di tipo diverso da a1, a2, a3, a4, b1, b2, c1 e c2 }

begin

  { Le seguenti istruzioni sono CORRETTE, perche le variabili a sinistra e
    a destra dell'asseganzione HANNO LO STESSO TIPO: }

  a1 := a2;   { corretto }
  a1 := a3;   { corretto }
  a1 := a4;   { corretto }

  b1 := b2;   { corretto }

  c1 := c2;   { corretto }

  d1 := d2;   { corretto }

  { Le seguenti istruzioni sono ERRATE, perche le variabili a sinistra e
    a destra dell'asseganzione NON hanno lo stesso tipo:

  b1 := a1;     ERRATO
  b1 := a4;     ERRATO

  c1 := a1;     ERRATO

  d1 := a1;     ERRATO
  d1 := c1;     ERRATO

  }

end. { CompatibilitaTraTipi }