From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.7 required=3.0 tests=BAYES_00,NICE_REPLY_A, REPLYTO_WITHOUT_TO_CC,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: "G.B." Newsgroups: comp.lang.ada Subject: Re: Safe to ignore warnings about function mistaken as primitive? Date: Mon, 11 Jul 2022 15:17:44 +0200 Organization: A noiseless patient Spider Message-ID: References: <864jzoclzv.fsf@stephe-leake.org> Reply-To: nonlegitur@notmyhomepage.de MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 11 Jul 2022 13:17:45 -0000 (UTC) Injection-Info: reader01.eternal-september.org; posting-host="643526d1fcf5a8d0557ae19a8e2d2be2"; logging-data="1807918"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19hLBDDluYp+nmH9tHi45yhMfyamIxvaIo=" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Cancel-Lock: sha1:Ke2N0FCmvyVkGFP3L6I2v++64DI= In-Reply-To: <864jzoclzv.fsf@stephe-leake.org> Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:64093 List-Id: On 11.07.22 06:27, Stephen Leake wrote: > Since B.F is declared in a sibling package, it cannot a primitive of > A.Some_Tagged, so the error message is wrong. > > Since A.Some_Tagged is an interface, you can only declare abstract > primitive subprograms for it. So I suspect GNAT knows there's an error, but is > giving a confusing error message. It seems possible to write programs declaring B.F (Param : A.Some_Tagged)..., but hardly one that isn't pointless! Adding "in out" to the function's Param allows 'Access using 'Class renames Ref'(Param'Access).all and then 'Unchecked_Access---so twisted I shan't repeat it here. Adding (... : access A.Some_Tagged) works a lot better (of course <:-|), and still has the warning. But, GNAT is right, I think! > How are you intending F to be different from FC? The first F was a bad choice, I guess; I had wanted to exclude a potentially larger interface. FC was the beginning of dropping F. FC now takes an access to class-wide. With Op1 added to the interface of Some_Tagged, package B is type Plain(<>) is private; function FC (Param : access A.Some_Tagged'Class) return Plain; procedure G (Item : in out Plain; Param : in Character); -- Calls Op1 of Item.Client private type Plain (Client : access A.Some_Tagged'Class) is record null; end record; end B; No F, no warning.