[comp.lang.modula2] opaque types

Pat.Terry@p101.f19.n490.z2.fidonet.org (Pat Terry) (08/06/89)

(* SEMI OPAQUE TYPES

The following silly program tests to see whether compilers will provide
for semi-opaque types - namely ones in which exporting an alias for
a record type will forbid access to the fields of the "original" type.

It is not suspected that any compilers would reject this code.  It
is suggested that, were the language to be slightly changed, this
would give a way of coding "limited private" types with no new syntax.

I would be curious to know whether any compilers to which I do not have
access would reject the code as it appears here.

*)


MODULE Test;

  MODULE Inner;
    EXPORT X (* but not Y*);
      TYPE
        Y = RECORD a : INTEGER END;
        X = Y;
    END Inner;

  VAR b : X;

BEGIN
  b.a := b.a
END Test.


(*
Collier V2               |  Accepted
FST                      |  Accepted
FTL                      |  Accepted
Logitech (MS-DOS 3.03)   |  Accepted
Stonybrook  (Quickmod)   |  Accepted
TopSpeed                 |  Accepted
Volition Sage/Stride     |  Accepted

*)


--  
uucp: {mcvax!uunet,tektronix,sun!nosun}!oresoft!dawggon!2!490!19.101!Pat.Terry
Internet: Pat.Terry@p101.f19.n490.z2.fidonet.org