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!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Overloading operator "=" for anonymous access types? Date: Wed, 16 Jan 2019 16:42:04 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <167dc83d-daac-49eb-ba79-48866ccde39d@googlegroups.com> <0c56d9f4-8861-4c74-b170-a973e3789b08@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:60.0) Gecko/20100101 Thunderbird/60.4.0 X-Mozilla-News-Host: news://news.aioe.org Content-Language: en-US X-Notice: Filtered by postfilter v. 0.8.3 Xref: reader01.eternal-september.org comp.lang.ada:55286 Date: 2019-01-16T16:42:04+01:00 List-Id: On 2019-01-15 22:00, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:q1k65j$1qqm$1@gioia.aioe.org... > ... >> [ The reference manual is shy to say anything about it. It claims that >> universal_access is kind of class-wide, which would mean, if taken >> seriously, that "=" overloads and must clash with the original "=". > > This is what happens. However, such a clash would mean that you could never > write a user-defined "=" for an anonymous access type. That would have been > a good idea, but it would have to have been enforced with a Legality Rule to > be sensible. Some thought that bad because of compatibility, so... > >> Since it does not, universal_access is more like a parent type than >> class-wide.] > > ...there is a hack to have a preference for the user-defined one. That > doesn't change the the fact that universal_access is class-wide, it just > make it possible to write a user-defined operator. Yes, you need hacks to handle inconsistencies and weaknesses. >> P.S. And, wouldn't it be better to fix the type system, no? > > This wart would be one of the things that would make "fixing the type > system" so much harder. A proper solution (and the one we should have used > in the first place) is to declare a "=" for every access type. I think we > wanted to avoid that as anonymous access can be declared in places where > declarations aren't allowed, so we came up with something worse. :-) I think the problem is that all operations with access T as an argument should be primitive operations of T. That was the idea behind anonymous access types all the time. But some types are not so much types to have classes. > It's the idea of anonymous access types that destroys the type system that > you have in mind. Your system keeps the types and operations together, and > that makes no sense for an anonymous type (what are the operations for an > anonymous type, and where are they declared? Any answer is either magical or > nonsense.) Yes, there is a conflict between anonymous access type treated as a standalone type and as a parameter passing mode of the target type. > One has to get rid of nonsense things before one could regularize the type > system, especially upon the lines you have been suggesting for years. It's > not really possible for Ada; you would end up with an Ada-like language. We may be able to express this in the terms of a more general type system. If anonymous access would be a mere user-defined type with all its perks that would be OK. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de