trijezdci
2015-10-28 09:07:33 UTC
I am trying to figure out whether Oberon allows addressing of a field in a record that is not present in said record's type declaration, but only in one of its extensions and do so without a type guard.
In PIO page 62, last sentence of the first paragaph, Wirth writes:
(1) "The further facility of the type guard is merely one of convenience."
In PIO page 59, first three sentences of the last paragraph before scetion 23.2 he writes:
(2) "The simple designator p.radius would not be acceptable, because p is of type Figure, which does not feature a field radius. With the type guard, the programmer can ascertain that in this case p is also of type Circle, in which case the field radius is indeed applicable. Whereas p is of base type Figure, p(Circle) is of type Circle."
On the one hand I interpret #2 such that the type guard is ***absolutely necessary*** in order to be able to address a field that is not in the designator's type declaration. Were it not for the type guard, addressing such a field should cause a compile time error.
On the other hand, if the type guard is merely a convenience as suggested by #1, then it could also be omitted. Its facility would simply be that of an assert and consequently the compiler could allow the addressing of a field that is not in the designator's type declaration.
Since the latter is not type safe I would be surprised if Wirth intended it that way.
I am therefore inclined to completely disregard #1.
How do Oberon implementors interpret this?
thanks in advance
In PIO page 62, last sentence of the first paragaph, Wirth writes:
(1) "The further facility of the type guard is merely one of convenience."
In PIO page 59, first three sentences of the last paragraph before scetion 23.2 he writes:
(2) "The simple designator p.radius would not be acceptable, because p is of type Figure, which does not feature a field radius. With the type guard, the programmer can ascertain that in this case p is also of type Circle, in which case the field radius is indeed applicable. Whereas p is of base type Figure, p(Circle) is of type Circle."
On the one hand I interpret #2 such that the type guard is ***absolutely necessary*** in order to be able to address a field that is not in the designator's type declaration. Were it not for the type guard, addressing such a field should cause a compile time error.
On the other hand, if the type guard is merely a convenience as suggested by #1, then it could also be omitted. Its facility would simply be that of an assert and consequently the compiler could allow the addressing of a field that is not in the designator's type declaration.
Since the latter is not type safe I would be surprised if Wirth intended it that way.
I am therefore inclined to completely disregard #1.
How do Oberon implementors interpret this?
thanks in advance