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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,9a4cc01431944b26 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!h48g2000cwc.googlegroups.com!not-for-mail From: "Adam Beneschan" Newsgroups: comp.lang.ada Subject: Re: Ada 2005: Attempting to create a useful subject/observer pattern Date: 24 Oct 2006 19:01:19 -0700 Organization: http://groups.google.com Message-ID: <1161741678.939019.275410@h48g2000cwc.googlegroups.com> References: <1161723710.859323.228560@f16g2000cwb.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1161741684 30272 127.0.0.1 (25 Oct 2006 02:01:24 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 25 Oct 2006 02:01:24 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: h48g2000cwc.googlegroups.com; posting-host=66.126.103.122; posting-account=cw1zeQwAAABOY2vF_g6V_9cdsyY_wV9w Xref: g2news2.google.com comp.lang.ada:7192 Date: 2006-10-24T19:01:19-07:00 List-Id: Lucretia wrote: > Hi, > > Like the subject states, I'm trying to implement a usable > subject/observer pattern which is an extension of the GoF original and > something closer to Java's Listeners. The idea was to use the code in a > gui library. After talking on IRC (#Ada) and working with the guys > there (Baldrick ;D), it was noted that GNAT is flawed in it's > interfaces, but I'd like to know if anyone here can indicate whether > the code is wrong and GNAT should accept it or not. > > I'm using FSF GNAT from GCC 4.1.1 and the errors are: I'll bite, but I'm not completely familiar with some of the new rules yet, and I had to look them up. So I could have easily gotten something wrong. > gnatmake -gnat05 test_observers2.adb > gcc -c -gnat05 test_observers2.adb > test_observers2.adb:16:34: (Ada 2005) interface subprogram "Update" > must be abstract or null This looks like a compiler problem, although since the declaration of the generic formal subprogram Update is illegal anyway, it's hard to tell what the compiler "should" have done. > test_observers2.adb:23:31: expected private type "Event" defined at > events.ads:5test_observers2.adb:23:31: found private type "Mouse_Event" > defined at mouse_events.ads:5 In the body of Test_Observers2, the second actual parameter to Notify_Mouse_Click has type Mouse_Events.Mouse_Event; but the second formal parameter has type Events.Event (as it's coded in the declaration of the Notify generic). Was the second parameter to Notify (and probably Update, as well) supposed to be Matching_Event? > my_observer.ads:10:03: (Ada 2005) interface subprogram "On_Mouse_Click" > must be abstract or null This looks like a compiler problem. > subjects.ads:15:10: (Ada 2005) interface subprogram "Update" must be > abstract or null This definitely looks like a compiler problem. > subjects.ads:15:20: operation can be dispatching in only one type This is a violation of RM05 12.6(8.4); it appears from your second post that you already figured that out, though. By the way: what is this? Oops. if Observer_Lists.Element(Current)'Class = Matching_Event'Class then ... -- Adam