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,start X-Google-Attributes: gid103376,public From: "Bobby D. Bryant" Subject: Generic package vs GTK callbacks. Date: 2000/01/31 Message-ID: <38955D00.FBBBA05D@mail.utexas.edu>#1/1 X-Deja-AN: 579828555 Content-Transfer-Encoding: 7bit X-Accept-Language: en,fr,de Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@cc.utexas.edu X-Trace: geraldo.cc.utexas.edu 949312832 10846 128.83.190.130 (31 Jan 2000 10:00:32 GMT) Organization: The University of Texas at Austin Mime-Version: 1.0 NNTP-Posting-Date: 31 Jan 2000 10:00:32 GMT Newsgroups: comp.lang.ada Date: 2000-01-31T10:00:32+00:00 List-Id: 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. (I can do this OK by instantiating it in the declaration part of some appropriate procedure that is called after the prompting, and which obtains the values previously stored in variables visible to that procedure, but I notice that AAA2ndL says that instantiating within a procedure declaration is "very rare", so if I'm going about this part wrongheadedly let me know -- it might obviate the question I'm asking below.) The problem arises because after instantiation I want to "talk to" the instantiated with GTK callbacks. I.e., I want to instantiate it and then let button clicks invoke its procedures, or at least let the button clicks invoke other procedures that invoke procedures in the generic package in turn. 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". Ditto if I try to use procedures local to the package for the callbacks[1]. But if I declare the callback functions elsewhere, they cannot see the instantiation at all. [1] The above is slightly simplified w.r.t. the actual problem: I am actually trying to "talk to" the generic child of a generic package. The description above is factual except that my "try to use procedures local to the package" actually refers to procedures local to the *child* package, which is instantiated at the same place the parent is. (Or better yet, I would like to have callback procedures that instantiate a new child of the previously instantiated parent.) Here's a schematic of what I'm up to (the actual code is *much* too large to post): ---8<------- -- The main program calls whatever.do_cool_stuff_with_map. with map, -- The generic package. map.child; -- The generic child package. package body whatever is -- XXX procedure do_cool_stuff_with_map is package this_map is new map( x => 100, y => 80 ) package this_map_child is new this_map.child( foo => foo_type'last ); -- i.e., "bar". -- YYY begin -- This procedure is called after the instantiation values (shown as constants -- above) have been loaded by other parts of the program. No problems there. -- Now I want to set up some GTK callbacks. By preference a callback would -- create another "new this_map.child()", but I could probably make an ugly -- workaround if I could get a callback to connect to a procedure in the child -- package at all. No luck either way. If I try to do it at XXX, then this_map -- is not visible. If I try to do it at YYY, then I get the "deeper than access type" -- problem. -- Notice that I don't have to leave the current procedure to finish the -- program, except in the sense that the callbacks always "leave" the local -- flow of control. end do_cool_stuff_with_map; begin -- Nothing important has to happen here. end whatever; --- 8<------- Is there a trick for working around this kind of problem? Thanks, Bobby Bryant Austin, Texas