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: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: "G.B." Newsgroups: comp.lang.ada Subject: Re: operation can be dispatching in only one type Date: Wed, 25 Nov 2015 13:27:08 +0100 Organization: A noiseless patient Spider Message-ID: References: <04eb6626-644b-4b16-a329-c35659a9fbe2@googlegroups.com> <1ephv5ugr5mib$.9ehadf3dddct$.dlg@40tude.net> Reply-To: nonlegitur@futureapps.de Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 25 Nov 2015 12:24:46 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="b96887e80893c84a90c3007226ca0d1c"; logging-data="25314"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19wXhv//9+YbdhHZcv13wI49+5YBO5Dn7I=" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 In-Reply-To: <1ephv5ugr5mib$.9ehadf3dddct$.dlg@40tude.net> Cancel-Lock: sha1:oQ24paMIecaQ0oyJB+YxjEjvH0w= Xref: news.eternal-september.org comp.lang.ada:28537 Date: 2015-11-25T13:27:08+01:00 List-Id: On 25.11.15 09:24, Dmitry A. Kazakov wrote: > On Tue, 24 Nov 2015 14:48:24 -0700, Jeffrey R. Carter wrote: > >> I mean that a protected type defines a set of values and operations on those >> values, > > This is a type, not yet a class. BTW, it is not even a proper class-type (a > root type in Ada terms) because you could not derive anything from it. > >> encapsulates the values and operations, and hides the implementation of >> the values. > > In fact it does not hide the implementation of values. I understand that for abstraction, you'd use abstraction features of the language. interface_type_definition ::= [limited | task | protected | synchronized] interface [and interface_list] That is, type Abstraction is protected interface; ... operations ... And then derive a concrete protected type that implements the interface: protected type Concrete is new Abstraction with ... > That is one of its > design flaws. The implementation of protected components is mixed with the > interface. Every Ada package tends to have "implementation of components" after "private", such as a full type definition? That's a long standing flaw then, justified by separate compilation needing full types. > It should have had public components with read access acting as > a protected function and write access doing as a protected procedure. The > private components should have been declared in the package's private > section or the package body. That seems approximately possible, I think, even when it is not formally possible: package Approx is type Opaque is private; Initial_Value : constant Opaque; protected type P is entry E1; function F1 return Boolean; private Data : Opaque := Initial_Value; end P; private type Index is range 1 .. 10; type Opaque is array (Index) of Boolean; Initial_Value : constant Opaque := (others => False); end Approx;