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, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8660fe29f138b478 X-Google-Attributes: gid103376,public From: Ted Dennison Subject: Re: Freezing question Date: 1999/07/20 Message-ID: <7n20f4$t1n$1@nnrp1.deja.com>#1/1 X-Deja-AN: 503119984 References: <7mlg18$qk0$1@nnrp1.deja.com> <378E57FE.FA7EEB99@averstar.com> <7mnc3q$f6r$1@nnrp1.deja.com> <379347D8.A902583C@averstar.com> <7mvp0h$333$1@nnrp1.deja.com> <37937E54.8D3AA9F0@mitre.org> X-Http-Proxy: 1.0 x25.deja.com:80 (Squid/1.1.22) for client 204.48.27.130 Organization: Deja.com - Share what you know. Learn what you don't. X-Article-Creation-Date: Tue Jul 20 14:18:26 1999 GMT X-MyDeja-Info: XMYDJUIDtedennison Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.6 [en] (WinNT; I) Date: 1999-07-20T00:00:00+00:00 List-Id: In article <37937E54.8D3AA9F0@mitre.org>, "Robert I. Eachus" wrote: > The usual is either to declare a class wide operation, and dispatch > in the body or to define the operation over a wider scope than necessary > and raise an exception when necessary. > type Widget is abstract tagged private; > procedure Add (Child : in out Widget; > Parent : in out Widget'Class); > type Container is abstract new Widget with private; > > ... > procedure Add (Child : in out Widget > Parent : in out Widget'Class) is > begin > if not Parent in Container'Class then raise ... end if; That's pretty much what I ended up doing. The only difference is that I had a "Container" operation to call, so I upcasted Parent to "Container'Class". I should get a constraint_error if it isn't in Container'Class. > Of course, IMHO, you want Widget and Container to be related so that > Parent is actually a wider class than Widget, but that is another > issue... I don't think so. There are operations that Containers need to perform that don't make sense for all Widgets (eg: Adding a child widget to manage). There are operations that all Widgets including containers need to be able to perform (redrawing themselves). Containers are just a kind of widget that has the extra capability of containing and managing other widgets. But a Container should be able to contain a widget that is not itself a container. %-) -- T.E.D. Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't.