From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,94b5e766f50facf2 X-Google-Attributes: gid103376,public From: Stephen Leake Subject: Re: Generic package vs GTK callbacks. Date: 2000/02/01 Message-ID: #1/1 X-Deja-AN: 580559868 References: <38955D00.FBBBA05D@mail.utexas.edu> X-Complaints-To: dscoggin@cne-odin.gsfc.nasa.gov X-Trace: skates.gsfc.nasa.gov 949446577 16537 128.183.220.71 (1 Feb 2000 23:09:37 GMT) Organization: NASA Goddard Space Flight Center NNTP-Posting-Date: 1 Feb 2000 23:09:37 GMT Newsgroups: comp.lang.ada Date: 2000-02-01T23:09:37+00:00 List-Id: "Bobby D. Bryant" writes: > I have a generic package that I want to instantiate at some arbitrary > depth in my code, so I can prompt for some user values before I > instantiate it. > > The problem arises because after instantiation I want to "talk to" the > instantiated with GTK callbacks. > > However, if I declare the callback functions within the declaration part > of the procedure that instantiates the package, GNAT complains with the > familiar "subprogram must not be deeper than access type". > > Is there a trick for working around this kind of problem? Unfortunately, you can't use 'Unchecked_Access for subprograms (RM 13.10 (5)). However, if you are using GNAT, you can try 'Unrestricted_Access. As the GNAT Reference Manual says, "this is a user-beware attribute"; you can get dangling references and other problems. From your description, I think you would be ok. Make sure you put in comments that "prove" you won't get dangling references; you need to understand when Gtk saves pointers, and when it frees them (usually when the associated object is "destroyed"). Good luck - I've just started using Gtk, and find it very confusing on this point. For a totally different approach, if you are on Win32, try using my Windex system (http://users.erols.com/leakstan/Stephe/Ada/windex.html) instead of Gtk. Windex takes a totally different approach to handling windows events; instead of requiring library-level "callbacks", you can define a local tagged window type and override the window event handler functions. I haven't needed to do this yet, but you can. Windex is _not_ as powerful as Gtk (yet), but this is one situation where it appears to be better :). -- Stephe