From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d10596e187e90822 X-Google-Attributes: gid103376,public From: "John Duncan" Subject: Re: Private Children Date: 1999/06/23 Message-ID: <7krjrn$ddi$1@usenet01.srv.cis.pitt.edu>#1/1 X-Deja-AN: 493104738 References: <7klja3$c0p$1@nnrp1.deja.com> <376E70A5.F77E558D@averstar.com> <376E9EEB.322A3F39@averstar.com> <7kmoe4$o83@dfw-ixnews15.ix.netcom.com> <7kr4pc$bb9@dfw-ixnews15.ix.netcom.com> Organization: University of Pittsburgh X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Newsgroups: comp.lang.ada Date: 1999-06-23T00:00:00+00:00 List-Id: >This example follows the Modula-2 convention for information >hiding using opaque types. Note that Modula-3 improves upon this >through reference types that are followed with a reserved word, >REVEAL,in the IMPLEMENTATION MODULE. Just a note: M3 allows the revelation of opaque subtypes at the interface level as well. That way you can publish a number of increasingly-challenging interfaces to a type, some of them unsafe, provided that the base implementation exports all of the interfaces. This way, you can have something like INTERFACE Thingy; TYPE T <: Public; TYPE Public = OBJECT METHODS safeMethods END; ... END Thingy; UNSAFE INTERFACE ThingyUnsafe; IMPORT Thingy; REVEAL Thingy.T <: Unsafe; TYPE Unsafe = Thingy.T OBJECT attributes METHODS unsafeMethods END; ... END ThingyUnsafe; UNSAFE MODULE Thingy EXPORTS ThingyUnsafe; IMPORT ThingyUnsafe; REVEAL T = ThingyUnsafe.Unsafe OBJECT moreAttributes METHODS moreMethods OVERRIDES ifaceMethod := MyMethodProcedure; END; ... END Thingy; The little "<:" operator tells the compiler about the subtyping relation. Each of the times T is declared as a subtype, it becomes more concrete, but not concrete enough to compile. When it comes down to the module level, someone has to define the type concretely. In order to do this, the methods are usually null until someone comes along and overrides the previous methods. It all works out very, very nicely. A lot of people on the m3 ng wonder whether the Ada committee reviewed opaque subtypes at all. It is a very neat feature for deep-down systems programming. There is no particular reason why unsafe things have to be published outside a library, but they are usually very useful within the library. That's where the opaque subtyping and partial revelations come in. (for more info on modula-3, go to http://www.m3.org/ ) -John