comp.lang.ada
 help / color / mirror / Atom feed
From: "Adam Beneschan" <adam@irvine.com>
Subject: Re: Ada 2005: Attempting to create a useful subject/observer pattern
Date: 24 Oct 2006 19:01:19 -0700
Date: 2006-10-24T19:01:19-07:00	[thread overview]
Message-ID: <1161741678.939019.275410@h48g2000cwc.googlegroups.com> (raw)
In-Reply-To: 1161723710.859323.228560@f16g2000cwb.googlegroups.com

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




  parent reply	other threads:[~2006-10-25  2:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-24 21:01 Ada 2005: Attempting to create a useful subject/observer pattern Lucretia
2006-10-24 21:08 ` Lucretia
2006-10-25  2:01 ` Adam Beneschan [this message]
2006-10-25  8:22 ` Dmitry A. Kazakov
2006-10-25 16:29 ` Matthew Heaney
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox