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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,36a29c2860aff686 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Properties Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <3b84c8e7-1a51-4a7c-9646-119f1fc51478@s4g2000yql.googlegroups.com> <4pnv7nl4cdui$.1n28i7lqk4mek$.dlg@40tude.net> <1k7367gtebsgm$.18auo6u3nfg34.dlg@40tude.net> <1u5dftkqqi68c.10079qnqyyfwb$.dlg@40tude.net> Date: Wed, 1 Dec 2010 22:13:23 +0100 Message-ID: <1qm78dl0lao3q$.2hxqpchz908z.dlg@40tude.net> NNTP-Posting-Date: 01 Dec 2010 22:13:22 CET NNTP-Posting-Host: 49684c5d.newsspool2.arcor-online.net X-Trace: DXC=a1`@OH2f;UV5TOT9_N5i On Wed, 1 Dec 2010 11:36:57 -0800 (PST), Shark8 wrote: >>> Agreed, but I don't believe we're stuck with that solution. >>> All you need is procedure'Access for the callback. >> >>No, because events have parameters and those must be typed. >>The standard solution is that you instantiate a generic (and >>there is one for each number of parameters and the results). >>That is extremely boring. > > Er, why not use OO/tagged-records for the events themselves and let > the base-handler have that as a parameter? > > i.e. the handler would be an access to something like this: > Procedure On_Event( Object : in out : GUI_Object; --'Class? > Event : In Base_Event'Class ); Yes, event handlers are naturally doubly dispatching, this is why you were not sure if On_Event should be a primitive operation of GUI_Object. It should and it also should be one of the Base_Event. Unless you downcast in the handler body. Another issue with the above is that you will have to derive from Base_Event somewhere this might be actually forbidden. On_Event is a closure, which is tend to be a subprogram rather than a primitive operation. Event parameters usually marshaled, which might be difficult. Yet another issue. Handlers actually connect the GUI object and the context of the handler. The context, if not of a closure, then another GUI object. E.g. normally one object catches events of another. In a GUI objects are usually collected. So you need a mechanism which disconnects the handler if any of the objects get destroyed. In any case it is probably triply dispatching: procedure On_Event (Emitter, Observer : in out : GUI_Object; Event : In Base_Event); -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de