Date: 9 Jul 84 15:11:02 PDT
From: Atkinson.pa
Subject: Re: Hidden Types
In-reply-to: "Your message of 28 Jun 84 18:21:14 PDT"
To: Nickell.Pasa
Cc: CedarFolklore^.pa
Reply-to: Atkinson.pa
Opaque types are only partially supported in Cedar, and full support is in the far distant future. One the biggest shortfalls is the inability to use opaque types in WITH ... SELECT statements or NARROW expressions. However, if you should want to use opaque types for the purpose of hiding information, and are willing to put up with their problems, then you may want to look at an example - PriorityQueueImpl. Here are the important things to remember:
The declaration in the interface is:
Ref: TYPE = REF Rep;
Rep: TYPE; -- the abstract type
The declaration in the implementation is:
Cvt: TYPE = REF Rep;
Rep: PUBLIC TYPE = RECORD [...]; -- the concrete type
For each procedure exported to the interface, use Cvt instead of Ref to get access to the fields of Rep. The path used to access Rep determines the visibility of the fields. The compiler will coerce Cvt to Ref in checking the types of the procedures. It matches the Rep used in the interface and the Rep used in the implementation by name. Obviously, Ref and Cvt need not match by name.