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 00:23:37 +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> NNTP-Posting-Host: 3CrKQyqWAJZHy6zYVP/kUg.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 X-Notice: Filtered by postfilter v. 0.8.3 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:53149 Date: 2018-06-19T00:23:37+02:00 List-Id: 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. 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; ... 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. P.S. Stepanov arguing for generics (templates) claimed that the reason why C++ needed this mess was impossibility to write Max using dynamic polymorphism. Generic Swap is a similar case. I believe it is possible to have a language where generic Max and Swap could be written without generics. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de