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,a218418d0394661d X-Google-Attributes: gid103376,public From: Richard D Riehle Subject: Re: Extended revelation Date: 2000/02/01 Message-ID: <875oc9$lk5$1@nntp3.atl.mindspring.net>#1/1 X-Deja-AN: 580206225 References: <873q03$alb$1@nnrp1.deja.com> <87446a$h6u$1@nnrp1.deja.com> Organization: MindSpring Enterprises X-Server-Date: 1 Feb 2000 04:44:57 GMT Newsgroups: comp.lang.ada Date: 2000-02-01T04:44:57+00:00 List-Id: In article <87446a$h6u$1@nnrp1.deja.com>, Jean-Marc Bourguet wrote: >I think indeed you have not understood what I want to do. What I really >want is something like modula-3 partial revelation: one package >providing multiples interface. In Ada95, a package has two interfaces, >one for the general public, one for his children. What I want is >multiple public interfaces. Until now, using child package has >permetted me to do this cleanly and here is the first example I come >with where I do not find a clean solution in Ada. You are correct about the excellent approach of Modula-3 in support of what some would call opaque types, a foundation mechanism for revelation. This can be done in Ada, but in a more awkward manner than in Modula-3. package P1 is type T1 is tagged private; -- other public declarations private type Data; type T1 is access Data; end P1; package body P1 is type Data is record ... end record; -- more declarations end P1; This is quite similar to the style used in Modula-2, if you remember that far back. It is similar to, but not as expressive as, the revelation mechanism in Modula-3. Sometimes we might want to make the private type extensible. package P2 is type T2 is tagged private; -- usually an abstract type -- other declarations private type Data; type Pointer is access Data; type T2 is tagged record X : Pointer; end record; end P2; This provides extensible inheritance while encapsulating all information about the Data in the implementing code. The package body will be coded to reflect the actual data. One benefit of this is the ability to acquire the data descriptions, at the implementation level, from some entirely different package, even a private child unit in the same hierarchy. In this respect, Ada has some benefits over Modula-3 in spite of its awkwardness vis a vis designing an opaque type. This goes back, again, to the issue of expressibility versus expressiveness. Modula-3 is much more expressive of opaque types than Ada. Ada is slightly more expressive of modular composition and independence than Modula-3. There is no perfect programming language. There is an upside, in expressiveness, to revelation. There is a downside in the branded reference mechanism required to support opaque types and revelation. Often, in Modula-3, an error is not discovered until link time. In Ada, every type mismatch will be caught at compile time. This may be one of those things that is seldom a problem, but it does become significant in a large scale software system consisting of lots of modules. Richard Riehle richard@adaworks.com