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!reader02.eternal-september.org!aioe.org!5WHqCw2XxjHb2npjM9GYbw.user.gioia.aioe.org.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Lower bounds of Strings Date: Sat, 9 Jan 2021 11:53:50 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <1cc09f04-98f2-4ef3-ac84-9a9ca5aa3fd5n@googlegroups.com> <37ada5ff-eee7-4082-ad20-3bd65b5a2778n@googlegroups.com> NNTP-Posting-Host: 5WHqCw2XxjHb2npjM9GYbw.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; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 X-Notice: Filtered by postfilter v. 0.9.2 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:61075 List-Id: On 2021-01-09 03:18, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:rtaeok$l8b$1@gioia.aioe.org... >> On 2021-01-08 18:23, Shark8 wrote: >>> On Thursday, January 7, 2021 at 3:03:54 PM UTC-7, Randy Brukardt wrote: >> >>>> Any sort of multiple inheritance (not to mention multiple dispatch) >>>> requires >>>> searching a lookup table for the appropriate interface. >>> Ah. >>> It appears you're confusing the Ada concept underlying keyword INTERFACE >>> with the general/abstract notion. >>> It appears to me that Dmitry is referring to the latter, not the >>> Ada-construct of INTERFACE, which requires a tagged type. >>> >>> I think what he's getting at is something that I considered/proposed here >>> on C.L.A some years ago, adding the concept of an "ABSTRACT INTERFACE" to >>> Ada. (IIRC, the proposal I had in mind was to be able to model the >>> notional meta type-hierarchy; eg: Number ? Universal_Integer ? >>> System.Integer.) >> >> Right, though I do not think that tags can inflict any cost. The situation >> is same as with array bounds. You do keep bounds when the array is >> statically constrained. Tag is just another constraint like bounds. It >> must be handled just same way, removed when statically known. No penalty, >> unless classes are actually used. I do not know why people always bring >> dispatch into discussions about static cases. > > The possibility of dynamic dispatch (in some code that doesn't exist yet, > but *could*) is what is so expensive and is virtually impossible to remove > after the fact (that is, in an optimizer). The representation without the tag must be mandatory. > If you wanted to include a > declaration that you *never* were going to use any dynamic dispatch, This declaration is already in the language. Only A'Class dispatches. Again, it is like with bounds, only array (... range <>) of ... has dynamic bounds. To enforce dispatch one would have to convert to A'Class first, that will add the tag to the array's dope vector. > then > you could talk try to ignore the possibility. But without some sort of > dispatch, a defined interface buys you nothing other than complication. It > doesn't simplify the description and would substantially complicate the > implementation. What's the point?? Of course it will simplify everything. E.g. our beloved generics. Compare generic type I is (<>); type E is private; type A is array (I range <>) of E; with generic type A is new Root_Array_Type with private; or package Ada.Containers.Vectors is ... type Vector is tagged private with Constant_Indexing => Constant_Reference, Variable_Indexing => Reference, Default_Iterator => Iterate, Iterator_Element => Element_Type; -- hundreds of operation declarations with type Vector is new array (Index_Type) of Element_Type with private; -- nothing else to declare Everything in Ada could be formalized in interfaces: type Index is new Discrete_Type; -- Same as <> type Discrete_Type is abstract new Ordered_Type and Copyable_Type; and so on. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de