Article View: comp.lang.modula2
Article #1489Re: Oberon-2, WITH-Statement, problem
From: Cheryl Lins
Date: Tue, 06 Oct 1992 21:22
Date: Tue, 06 Oct 1992 21:22
83 lines
2534 bytes
2534 bytes
In article <1992Oct6.195605.22657@email.tuwien.ac.at> ulrich@mips.complang.tuwien.ac.at writes:
>(*
> Hello, I have some problems in understanding the WITH-statement
> in Oberon-2 and would appreciate some help.
>
> As far as I understood the Oberon-2 report, the procedure Subel1
> below, should be equivalent to the procedure Subel2.
> However, in Subel2 an error is reported by the compiler.
> Even if a type guard is added (Subel3), the error remains.
> (The procedures are a stripped down version of some more
> useful code, indeed.)
>
> The platform was DECoberon Release 2.6
> (Oberon.2.6.tar.Z last modified Oct 3 21:09)
>
>
> Thanks in advance
> Ulrich
>*)
>
>MODULE StatementWITH;
>TYPE
> T0 = POINTER TO T0X;
> T0X = RECORD END;
>
> T1 = POINTER TO T1X;
> T1X = RECORD(T0X) ARG: POINTER TO ARRAY OF T0 END;
>
>PROCEDURE Subel1(t0: T0);
>BEGIN
> Subel1(t0(T1).ARG[0])
>END Subel1;
>
>PROCEDURE Subel2(t0: T0);
>BEGIN
> WITH t0: T1 DO
> Subel2(t0.ARG[0]) (* error 113 "incompatible assignment *)
> END
>END Subel2;
>
>PROCEDURE Subel3(t0: T0);
>BEGIN
> WITH t0: T1 DO
> Subel3(t0(T1).ARG[0]) (* error 113 "incompatible assignment" *)
> END
>END Subel3;
>END StatementWITH.
>
A version that compiles follows:
[types and Subel1 deleted]
PROCEDURE Subel2(t0: T0);
VAR
t: T0;
BEGIN
WITH t0: T1 DO
t := t0.ARG[0];
END;
Subel2 (t)
END Subel2;
(* it looks like a front-end bug in Subel2 as there should be no difference
between assignment to a variable and passing the designator as a param
(at least in this case.)
*)
PROCEDURE Subel3(t0: T0);
BEGIN
Subel3(t0(T1).ARG[0])
END Subel3;
(* The WITH statement is unnecessary with the guard. *)
I have written quite a bit of code using the WITH statement and haven't
encountered this bug. I suspect it's related to the use of the open array
rather than a general problem with WITH statements.
--
Cheryl Lins Oberon Paladin lins@apple.com
Technical Details
Message-ID:
<1992Oct6.212228.3016@gallant.apple.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!noc.near.net!hri.com!spool.mu.edu!agate!apple!mumbo.apple.com!gallant.apple.com!cherylReferences:
<1992Oct6.195605.22657@email.tuwien.ac.at>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!noc.near.net!hri.com!spool.mu.edu!agate!apple!mumbo.apple.com!gallant.apple.com!cheryl From: cheryl@gallant.apple.com (Cheryl Lins) Newsgroups: comp.lang.modula2 Subject: Re: Oberon-2, WITH-Statement, problem Summary: looks like compiler bug Keywords: WITH, Oberon-2, DECoberon Message-ID: <1992Oct6.212228.3016@gallant.apple.com> Date: 6 Oct 92 21:22:28 GMT References: <1992Oct6.195605.22657@email.tuwien.ac.at> Organization: Apple Computer Inc, Cupertino, CA Lines: 83