From: "G.B." <bauhaus@notmyhomepage.invalid>
Subject: Re: Safe to ignore warnings about function mistaken as primitive?
Date: Mon, 11 Jul 2022 15:17:44 +0200 [thread overview]
Message-ID: <tah7tp$1n5he$1@dont-email.me> (raw)
In-Reply-To: <864jzoclzv.fsf@stephe-leake.org>
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.
prev parent reply other threads:[~2022-07-11 13:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-10 8:45 Safe to ignore warnings about function mistaken as primitive? G.B.
2022-07-10 10:19 ` Dmitry A. Kazakov
2022-07-11 4:27 ` Stephen Leake
2022-07-11 13:17 ` G.B. [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox