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!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Ada Successor Language Date: Tue, 19 Jun 2018 09:50:50 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <5e86db65-84b9-4b5b-9aea-427a658b5ae7@googlegroups.com> <878t7u1cfm.fsf@nightsong.com> <776f3645-ed0c-4118-9b4d-21660e3bba4b@googlegroups.com> <3e410d4c-60d9-4adf-82fe-5d6b2272804e@googlegroups.com> NNTP-Posting-Host: MyFhHs417jM9AgzRpXn7yg.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:52.0) Gecko/20100101 Thunderbird/52.8.0 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.8.3 Xref: reader02.eternal-september.org comp.lang.ada:53156 Date: 2018-06-19T09:50:50+02:00 List-Id: On 2018-06-19 04:45, Shark8 wrote: > On Monday, June 18, 2018 at 4:23:41 PM UTC-6, Dmitry A. Kazakov wrote: >> On 2018-06-18 23:20, Shark8 wrote: >>> On Monday, June 18, 2018 at 2:45:39 PM UTC-6, Niklas Holsti wrote: >>>> On 18-06-18 23:22 , Jeffrey R. Carter wrote: >>>>> On 06/18/2018 09:16 PM, Niklas Holsti wrote: >>>>>> >>>>>> Nah... invites "Ada'Succ sucks". >>>>> >>>>> Also, in Ada, Ada'Succ is not the successor of Ada. >>>> >>>> But perhaps the successor language will let us write X'Succ as an >>>> abbreviation of X_Type'Succ(X) ... similarly to the recent introduction >>>> of X'Image. >>> >>> I'd honestly like the ability to use X'Type; this would allow us to say something like this: >>> >>> Procedure Swap( A, B : in out Some_Type ) is >>> Temp : Constant B'Type := B; >>> Begin >>> B:= A; >>> A:= Temp; >>> End Swap; >>> >>> Yeah, I know, it's a little thing and you can do it with generics, etc. But that's not entirely the point, the point is that this allows the declaration of types dependent on objects... it provides some of the niceties of type-inference without having to resort to such lazy/possibly-error-prone methodologies. >> >> It is not a little thing. It requires classes for all types. > > No, it doesn't. > A 'Type attribute could simply mean "the [sub]type of this object", and thereby given "A : Positive" we know that A'Type is positive, statically, at compile time, and without any notion of classes. X'Type is useless because it does not reveal anything about the type, e.g. if you can assign it. X can be a task. And you cannot use it in declaration without having an object. >> Then all types with assignment (non-limited types) will be members of >> the class Not_Limited [*]. E.g. >> >> type Integer is ... and Not_Limited; >> type String is ... and Not_Limited; >> ... > > Why would they need to have a Not_Limited class? We already know they're not limited from the type declaration "Type Integer is new System.Integer;"... You must be able to declare a class-wide non-limited object in order to define an operation dealing with it. It is just what strong manifested typing is. > We can currently use the generic-language "type T (<>) is abstract tagged limited private;" to specify "Any tagged type, abstract or concrete, limited or not." Integer is not tagged. >> Then you could write a class-wide Swap: >> >> procedure Swap (A, B : in out Not_Limited'Class) is >> Temp : constant Not_Limited'Class := B; >> begin >> B := A; >> A := Temp; >> end Swap; >> >> ----------------------------- >> * You must also deal with type cloning, so that >> >> type X is new Integer; >> >> will get its own copy of the Not_Limited class. I.e. the whole type tree >> must be copied. It is not a little thing. > > Why would it need a Not_Limited class? It looks like you're trying to combine regular "Interface" with the attributes-and-classification of the type. I don't know what "regular interface" is, but each type implements a lot of interfaces, most of which are implicit in Ada. E.g. Integer is copyable (has ":="), comparable (has "="), ordered (has ">"), additive group (has "+") etc. If these interfaces were explicit and allowed run-time instances (class-wide objects of) then things like Swap would work right off the shelf. We could write generic algorithms (as in Stepanov's STL) in terms of these interfaces rather than in terms of generic instances. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de