
>Oberon-2 *restriction* proposal
: With respect to dynamic type testing and guarding,
: Oberon-2 offers some redundancy:
: (i) type test (VarIdent "IS" TypeIdent),
: (ii) type guard (VarIdent "(" TypeIdent ")"),
: (iii) type tests with regional type guards ("WITH" statement).
: (Recall that the WITH statement was promoted from a simple
: regional type guard in Oberon(-1) to a multi-case type test
: with guards in Oberon-2.)
: Actually, (iii) covers (i) and (ii) and would thus be sufficient.
I'm wondering for long, for what good a type guard without any previous
type test is. Apart from very seldom cases, where I don't care about a
user's reaction to a trap, caused by a failed type guard.
: BTW, I find the function-like syntax of (ii) VarIdent "(" TypeIdent ")"
: particularly confusing. IMHO, at least (ii) could be dropped.
It's also confusing when writing a formal language specification which
is oriented by the traditional compiler phases: A parser needs to examine
context information to decide whether Ident1(Ident2) is a function call or
a type guard. As a possible solution M. Odersky suggests in "A New
Approach to Formal Language Definition and Its Application to Oberon"
the usage of "(v::T).f" instead of "v(T).f". I would like to hear the
reasons, why the ambiguous construct was chosen by the language designer.
Another strange issue of this subject is that only qualidents are
legal as "WITH-Expressions" (Guard = Qualident ":" Qualident.).
I.e. if you have
TYPE T=POINTER TO ObjDescr; ObjDescr=RECORD ... END;
VAR v:ARRAY n OF T;
it is legal to speak of
v[i](T)
but you are not allowed to write
WITH v[i] : T DO.
Are there any deeper causes for this dis-orthogonality?
Finally, I think the definition of the with-statement in the
oberon-2 language report in terms of an example like
"...the statement
WITH v: T1 DO S1 | v: T2 DO S2 ELSE S3 END
has the following meaning: ..."
is maybe a bit unfortunate. E.g. has the "withed" variable always to be
the same in all with-cases? If not, what could it be good for, to use
different "withed" variables?
Max Spring.