0

The Oberon-2 language report "The Programming Language Oberon–2" has the following definition in appendix A:

Two variables a and b with types Ta and Tb are of the same type if

  1. Ta and Tb are both denoted by the same type identifier, or
  2. Ta is declared to equal Tb in a type declaration of the form Ta = Tb, or
  3. a and b appear in the same identifier list in a variable, record field, or formal parameter declaration and are not open arrays.

Given the type declarations

Ta = INTEGER
Tb = INTEGER
Tc = Tb

paragraph two in the above definition suggests that

  • Ta and Tb are different types (no declaration of Ta = Tb),
  • Ta and Tc are different types (no declaration of Ta = Tc) and
  • Tc and INTEGER are different types (no declaration of Tc = INTEGER).

Is this a correct interpretation of same type in Oberon-2? As far as I understand, Oberon-2 is quite strict when it comes to name equivalence, and in this context the interpretation actually makes sense. What about Standard Pascal and ISO Modula-2?

August Karlstrom
  • 10,773
  • 7
  • 38
  • 60
  • 1
    In Pascal, INTEGER is a predefined type identifier, so Ta, Tb, and Tc would all be the same type. My guess is that the same is true for Oberon-2. – Stuart Oct 12 '17 at 02:19

1 Answers1

2

The interpretation of same type in the question follows what is called strict name equivalence. In Ada, for instance, this feature is supported through derived types. Under strict name equivalence each type declaration introduces a distinct type. Pascal, Modula-2 and Oberon, however, all use non-strict name equivalence. This means that for a type identifier Ta, the declarations Tb = Ta and Tc = Ta make Tb and Tc equivalent.

August Karlstrom
  • 10,773
  • 7
  • 38
  • 60