[Oberon] Clarifying type compatibility in Oberon-07
    August Karlstrom 
    fusionfile at gmail.com
       
    Wed Oct 11 15:26:18 CEST 2017
    
    
  
On 2017-10-11 10:27, Andreas Pirklbauer wrote:
 > "Question:
 >
 > How is this code (“code A”):
 >
 >   VAR
 >     nbrOfBirthsPerMonth: ARRAY 12 OF INTEGER;
 >     nbrOfAccidentsPerMonth: ARRAY 12 OF INTEGER;
 >
 >   nbrOfBirthsPerMonth := nbrOfAccidentsPerMonth; (*these match 
structurally but makes not much sense, should be forbidden*)
 >
 > CONCEPTUALLY different from the following code (“code B”):
 >
 >   VAR
 >     nbrOfBirthsPerMonth: INTEGER;
 >     nbrOfAccidentsPerMonth: INTEGER;
 >
 >     nbrOfBirthsPerMonth := nbrOfAccidentsPerMonth; (*allowed, but 
*also* makes not much sense*)
 >
 > when in comes to name equivalence vs structural equivalence?"
As pointed out by Diego, ARRAY 12 OF INTEGER is a type constructor which 
creates a new type, whereas INTEGER is the name of an existing type. So 
in code A the variables have different types, and in code B they have 
the same type.
(Andreas, for some reason all your messages consistently end up in my 
Gmail spam folder. I don't understand the reason for this.)
-- August
    
    
More information about the Oberon
mailing list