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,WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED.2uCIJahv+a4XEBqttj5Vkw.user.gioia.aioe.org!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: "subprogram must not be deeper than access type" Date: Sat, 3 Oct 2020 08:41:56 +0200 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: 2uCIJahv+a4XEBqttj5Vkw.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.3.1 X-Notice: Filtered by postfilter v. 0.9.2 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:60394 List-Id: 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