From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED.2uCIJahv+a4XEBqttj5Vkw.user.gioia.aioe.org!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Proposal: Auto-allocation of Indefinite Objects Date: Fri, 31 Jul 2020 12:20:07 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <94a54092-a56f-4a99-aaec-08dd611c8fd8@googlegroups.com> NNTP-Posting-Host: 2uCIJahv+a4XEBqttj5Vkw.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:68.0) Gecko/20100101 Thunderbird/68.11.0 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader01.eternal-september.org comp.lang.ada:59610 List-Id: On 31/07/2020 11:25, Stephen Davies wrote: > On Friday, 3 April 2020 at 23:48:43 UTC+1, Stephen Davies wrote: >> type Node_Type is record >> Item : new Element_Type; >> Prev : Node_Ptr_Type; >> Next : Node_Ptr_Type; >> end record; > > Perhaps a better way to think of this is as a discriminated record without > an explicit discriminant? In which case maybe a different syntax than "new" > would be appropriate? That is right, but it would be a much larger problem to resolve than your original proposal. First, Ada lacks necessary discriminants, e.g. type Node_Type (Descendant : Ada.Tags.Tag) is record Item : Element_Type (Tag => Descendant); Prev : Node_Ptr_Type; Next : Node_Ptr_Type; end record; Here Element_Type is a specific type from Element_Type'Class which tag is Descendant. Second, Ada's object initialization process has no means to determine discriminants. One extra step is missing before a call to allocator to provide constraints of a type. [I proposed a record type T'Constraints that would contain all constraints and no data to be passed to allocator to determine the object constraints and thus its size.] Third, there is still the problem that task components do not work, as well as all other cases when the Rosen trick is used to work-around full multiple inheritance by making record members out of intended parents. All in one, the crude work-around has always been an access type, which your original proposal would handle with much more grace. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de