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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: border1.nntp.dca3.giganews.com!backlog4.nntp.dca3.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!news.stack.nl!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: 'Protected' abstract subprograms Date: Wed, 15 Jan 2014 10:17:05 +0100 Organization: cbb software GmbH Message-ID: <1aav8alqsnqqv.5urmifgwh1mv.dlg@40tude.net> References: <839fee13-2743-49f6-a7f3-f95578386201@googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: I5Na6+WsEzT8WoegI0VZTA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 X-Original-Bytes: 4256 Xref: number.nntp.dca.giganews.com comp.lang.ada:184425 Date: 2014-01-15T10:17:05+01:00 List-Id: On Tue, 14 Jan 2014 18:36:13 -0600, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:on1zhsdlciqw.70mg9osrtb80$.dlg@40tude.net... >> On Mon, 13 Jan 2014 21:45:24 -0600, Randy Brukardt wrote: >> >>> Yes, but that would require some way of specifying that the private type >>> cannot be extended anywhere *other* than a child of the package >>> containing >>> the private type. >> >> Doesn't >> >> type T is private; >> >> already do? It could be reused like >> >> type T is private [abstract] new ... with ...; > > I don't understand. The OP would like to restrict the extensions of private > type T to child packages, because those already can "see" that overriding of > private abstract operations is needed. That would require some additional > marking of the private type T in the specification of a package to avoid > breaking privacy (legality rules cannot depend on the contents of the > private part). Hmm, of course they can and do. Do you mean legality of public part not depending on the legality of private parts? Even they do. Regarding private types, I mean that when T is declared private one cannot extend it publicly but still can do privately. The following is legal Ada, AFAIK: type T is limited private; private type T is new Ada.Finalization.Limited_Controlled with null record; type S is new T with null record; There is no obvious harm to allow: type T is abstract limited private; private type T is abstract new Ada.Finalization.Limited_Controlled with null record; procedure Foo (X : T) is abstract; and, more useful: type T is private abstract new Ada.Finalization.Limited_Controlled with private; private type T is abstract new Ada.Finalization.Limited_Controlled with null record; procedure Foo (X : T) is abstract; -- OK Because T is publicly private it cannot be extended publicly and so allowed to have private abstract operations. [Not that I propose this sort of language extension] >>> As I said last week, Ada takes privacy very seriously, >> >> Moderately serious I would say. In numerous cases privacy does not hold. >> Worse is that frequently privacy cannot be imposed or requires serious >> changes in the structure of types. > > Privacy (like other visibility rules) is a compile-time construct only. Yep, that's what I meant under "cooperative" privacy. For many applications, and the number of is growing rapidly, a "non-cooperative" privacy is needed as well. > Run-time features (like representation or dynamic checking) are not affected > by privacy (or visibility). I'm not aware of any cases where privacy does > not hold at compile-time - it is taken *very* seriously by Ada. Just one trivial example of slack privacy. You cannot hide default values: type T is private; procedure Foo (X : T := V); private type T is ... Should have been something like: type T is private; procedure Foo (X : T := <>); -- The value is deferred private type T is ... for Foo'Default (X) use V; -- Here it is, whichever syntax you prefer -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de