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 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: Tue, 6 Oct 2020 08:08:04 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <3139cefa-f8e1-4fc1-be15-2615eeaa89fdn@googlegroups.com> 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:60408 List-Id: On 06/10/2020 06:00, andrew...@gmail.com wrote: > On Saturday, October 3, 2020 at 2:42:01 AM UTC-4, Dmitry A. Kazakov wrote: > I guess I'm not sure what you mean by #1. The handler package contains another package, Callback. And the compiler never really gets to the methods (Destroy and Delete_Event), it stops when I try to create a new package from an existing one. It stops on compiling a call to connect a handler to the event. The handler is declared deeper than the pointer the event uses to refer to the handler. The language requires that in order to prevent the situation when the handler ceases to exist but the event still may be emitted. > Could you please show me an example of what you mean? ----------------------------------------------------------------- with Gtk.Widget; use Gtk.Widget; package My_Handlers is function Delete_Event (Widget : access Gtk_Widget_Record'Class) return Boolean; procedure Destroy (Widget : access Gtk_Widget_Record'Class); end My_Handlers; ----------------------------------------------------------------- with Gtk.Main; package body My_Handlers is function Delete_Event (Widget : access Gtk_Widget_Record'Class) return Boolean is begin return False; end Delete_Event; procedure Destroy (Widget : access Gtk_Widget_Record'Class) is begin Gtk.Main.Main_Quit; end Destroy; end My_Handlers; ----------------------------------------------------------------- with Gtk.Label; with Gtk.Window; with Gtk.Widget; with Gtk.Handlers; with Gtk.Main; with My_Handlers; procedure Event_Handlers_Window is Window : Gtk.Window.Gtk_Window; Label : Gtk.Label.Gtk_Label; begin Gtk.Main.Init; Gtk.Window.Gtk_New (Window); Gtk.Label.Gtk_New (Label, "Goodbye, World!"); Gtk.Window.Add (Window, Label); Window.On_Delete (My_Handlers.Delete_Event'Access); -- Connect handler Window.On_Destroy (My_Handlers.Destroy'Access); Gtk.Label.Show_All (Label); -- Could drop this and use Gtk.Window.Show (Window); -- Show_All here Gtk.Main.Main; end Event_Handlers_Window; ----------------------------------------------------------------- > Also, I looked through the docs and couldn't find Gtk.Missed... did you mean some other method/package? http://www.dmitry-kazakov.de/ada/gtkada_contributions.htm#5 Scroll down to the declarations of Delete_Event_Handler Destroy_Handler -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de