Discussion:
Type tests in Oberon-07
(too old to reply)
August Karlstrom
2011-10-06 21:57:12 UTC
Permalink
In section 8.2.4 in the language report it is stated that a type test is
applicable if "v is a variable parameter of record type or v is a
pointer." Since all non-scalar parameters are passed by reference in
Oberon-07 I think type tests are (should be) applicable to all record
parameters. Is this an oversight or have I missed something?

http://www.inf.ethz.ch/personal/wirth/Articles/Oberon/Oberon07.Report.pdf


August

--
The competent programmer is fully aware of the limited size of his own
skull. He therefore approaches his task with full humility, and avoids
clever tricks like the plague. --Edsger Dijkstra
Richard
2011-10-07 17:44:42 UTC
Permalink
Post by August Karlstrom
In section 8.2.4 in the language report it is stated that a type test
is applicable if "v is a variable parameter of record type or v is a
pointer." Since all non-scalar parameters are passed by reference in
Oberon-07 I think type tests are (should be) applicable to all record
parameters. Is this an oversight or have I missed something?
I think, the reason is that only pointers and variable parameters may
have a dynamic type, i.e. a run-time type extended from their declared
static type. Only for them it makes sense to perform a type test at
run time.

Value parameters always have the type of the formal parameter
declaration, no matter if they are passed by value or by reference. If
you pass a record of an extended type as value parameter, it is
automatically converted to the declared (base) type of the formal
parameter, and within the procedure only the fields of this type can
be accessed.

Richard
August Karlstrom
2011-10-08 11:37:04 UTC
Permalink
Post by Richard
Post by August Karlstrom
In section 8.2.4 in the language report it is stated that a type test
is applicable if "v is a variable parameter of record type or v is a
pointer." Since all non-scalar parameters are passed by reference in
Oberon-07 I think type tests are (should be) applicable to all record
parameters. Is this an oversight or have I missed something?
I think, the reason is that only pointers and variable parameters may
have a dynamic type, i.e. a run-time type extended from their declared
static type. Only for them it makes sense to perform a type test at run
time.
Value parameters always have the type of the formal parameter
declaration, no matter if they are passed by value or by reference. If
you pass a record of an extended type as value parameter, it is
automatically converted to the declared (base) type of the formal
parameter, and within the procedure only the fields of this type can be
accessed.
OK, thanks for the explanation, Richard. It makes sense now.


August
--
The competent programmer is fully aware of the limited size of his own
skull. He therefore approaches his task with full humility, and avoids
clever tricks like the plague. --Edsger Dijkstra
Loading...