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.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Class-wide types algebra Date: Mon, 12 Sep 2016 22:26:19 +0200 Organization: Aioe.org NNTP Server Message-ID: NNTP-Posting-Host: 4UnmtEBiFcCZzQad+30FUw.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 X-Mozilla-News-Host: news://news.aioe.org:119 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:31756 Date: 2016-09-12T22:26:19+02:00 List-Id: Presently class-wide types are singletons. I would propose to extend that to call-wide expressions, namely conjunction in all places where T'Class is expected. e.g. procedure Foo (X : in out T'Class and R'Class); -- Not Ada task type Worker (X : not null access T'Class and R'Class) is if X is in (T'Class and R'Class) then Object : T'Class and R'Class renames (T'Class and R'Class) (X); It should not be difficult, at first glance. Rationale. Presently it is impossible to declare an operation requiring an instance derived from the type T that also implements interface R. We cannot do that without having a explicit root type type T_And_R is new T and R with ...; But that will exclude existing types already implementing T. If we already have: type S is new T with ...; A type derived from S with R added would not fall into T_And_R. Generics do not help much because descendants of T may have discriminants which are all unknown in advance, so there is no chance to create instances derived types. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de