From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: "subprogram must not be deeper than access type"
Date: Sat, 3 Oct 2020 08:41:56 +0200 [thread overview]
Message-ID: <rl96fk$sh2$1@gioia.aioe.org> (raw)
In-Reply-To: a6cd1af8-4635-4375-bb68-be5ca2668459n@googlegroups.com
On 03/10/2020 06:39, andrew...@gmail.com wrote:
> Hello,
>
> I'm trying my hand at a small rosettacode.org example:
>
> https://codeshare.io/an080j
>
> What I don't understand is when I'm creating the various packages to serve as handlers, I get the following compile-time errors:
>
> gprbuild : event_handlers_window.adb:13:03: instantiation error at gtk-handlers.ads:1039
> event_handlers_window.adb:13:03: subprogram must not be deeper than access type
> event_handlers_window.adb:14:03: instantiation error at gtk-handlers.ads:437
> event_handlers_window.adb:14:03: subprogram must not be deeper than access type
>
> How am I making a subprogram deeper than an access type exactly?
The access type to the handler function is declared at the library
level. Your handler subprogram is declared inside the body of
Event_Handlers_Window, which is one step deeper than the library level.
You can:
1. Move the handler function into a package. A library package would be
on the same level with the access type declaration. That is the
recommended way.
2. You can circumvent accessibility checks by declaring a local access
type to the function in the procedure (which would be same level) and
then convert from this type to the handler type using
Unchecked_Conversion. This is not recommended, obviously.
3. Specifically for delete and destroy events in GtkAda Contributions
the package Gtk.Missed defines ready-to-use handlers as in the solution #1.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2020-10-03 6:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-03 4:39 "subprogram must not be deeper than access type" andrew...@gmail.com
2020-10-03 6:41 ` Dmitry A. Kazakov [this message]
2020-10-06 4:00 ` andrew...@gmail.com
2020-10-06 6:08 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox