[Oberon] A pseudo-problem?
vrotaru at seznam.cz
Tue Dec 9 12:22:49 CET 2003
"Daniel Keller" <keller at creacare.com> wrote:
> We will try to make Paco complient to the standard. Paco will support at least WITH := Qualident : Qualident. Ev. WITH := Designator
> : Qualident, but that's not clear yet.
Well, (as Svejk will have been said) "if we are conversating now so
nicely" may I ask why the support for Oberon-2 WITH was dropped in
Active Oberon (Paco)?
Just that WITH is not widely used in the Oberon sources, or are the
more subtle reasons? Anyone at ETH who knows the story?
> We also will give up the perfomance gain of WITH and introduce type checks so that the following will trap:
> (* type Child is extension of type Parent *)
> PROCEDURE Bar(p: Parent);
> PROCEDURE NewParent;
> END NewParent;
> IF p IS Child THEN
> WITH p: Child DO
> (* p has dynamic type Parent, but fields of Child are still accessible !!! *)
> END Bar;
I see, (down/up)casting in a WITH statement may be a dangerous/unsafe
thing to do. So, even the simplest languages have the dark corners..
Maybe just a price to pay for "dinamicity".
But are the runtime checks really necessary? Would it not suffice to
make the "casted" pointer immutable/readonly within a WITH statement? It
makes perfect reason with me, and this can be checked at compile-time,
if i guess correctly. (Not a trivial task still, as your example shows)
> You cannot do
> WITH foo.bar: Bar DO (* stuff *) END;
> either using Compiler OR PC. Still the Oberon Report states clearly:
> WITH qualident : qualident DO .. END;
More information about the Oberon