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=-0.9 required=3.0 tests=BAYES_00,FREEMAIL_FROM, PDS_FROM_2_EMAILS,WEIRD_PORT autolearn=no autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:ac8:6f49:: with SMTP id n9mr3347441qtv.143.1601956830993; Mon, 05 Oct 2020 21:00:30 -0700 (PDT) X-Received: by 2002:a05:620a:20db:: with SMTP id f27mr3605233qka.11.1601956830823; Mon, 05 Oct 2020 21:00:30 -0700 (PDT) Path: eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!2.eu.feeder.erje.net!feeder.erje.net!feeder5.feed.usenet.farm!feeder1.feed.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 5 Oct 2020 21:00:30 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=2601:18f:900:4870:d8d7:d43e:50a0:ceba; posting-account=3pYsyQoAAACcI-ym7XtMOI2PDU8gRZS5 NNTP-Posting-Host: 2601:18f:900:4870:d8d7:d43e:50a0:ceba References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <3139cefa-f8e1-4fc1-be15-2615eeaa89fdn@googlegroups.com> Subject: Re: "subprogram must not be deeper than access type" From: "andrew...@gmail.com" Injection-Date: Tue, 06 Oct 2020 04:00:30 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:60405 List-Id: On Saturday, October 3, 2020 at 2:42:01 AM UTC-4, Dmitry A. Kazakov wrote: > On 03/10/2020 06:39, andrew...@gmail.com wrote:=20 > > Hello,=20 > >=20 > > I'm trying my hand at a small rosettacode.org example:=20 > >=20 > > https://codeshare.io/an080j=20 > >=20 > > What I don't understand is when I'm creating the various packages to se= rve as handlers, I get the following compile-time errors:=20 > >=20 > > gprbuild : event_handlers_window.adb:13:03: instantiation error at gtk-= handlers.ads:1039=20 > > event_handlers_window.adb:13:03: subprogram must not be deeper than acc= ess type=20 > > event_handlers_window.adb:14:03: instantiation error at gtk-handlers.ad= s:437=20 > > event_handlers_window.adb:14:03: subprogram must not be deeper than acc= ess type=20 > >=20 > > How am I making a subprogram deeper than an access type exactly? > The access type to the handler function is declared at the library=20 > level. Your handler subprogram is declared inside the body of=20 > Event_Handlers_Window, which is one step deeper than the library level.= =20 >=20 > You can:=20 >=20 > 1. Move the handler function into a package. A library package would be= =20 > on the same level with the access type declaration. That is the=20 > recommended way.=20 >=20 > 2. You can circumvent accessibility checks by declaring a local access=20 > type to the function in the procedure (which would be same level) and=20 > then convert from this type to the handler type using=20 > Unchecked_Conversion. This is not recommended, obviously.=20 >=20 > 3. Specifically for delete and destroy events in GtkAda Contributions=20 > the package Gtk.Missed defines ready-to-use handlers as in the solution #= 1.=20 >=20 > --=20 > Regards,=20 > Dmitry A. Kazakov=20 > http://www.dmitry-kazakov.de Hi Dmitry, Thanks for writing back. I guess I'm not sure what you mean by #1. The handler package contains ano= ther 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 fro= m an existing one. Could you please show me an example of what you mean? Also, I looked through the docs and couldn't find Gtk.Missed... did you mea= n some other method/package? Thank you, --Andrew