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,b99ea713360acf25,start X-Google-Attributes: gid103376,public From: chipr@niestu.com (Chip Richards) Subject: Help a dope Date: 1998/05/09 Message-ID: <6j1ugm$87q@tomquartz.niestu.com>#1/1 X-Deja-AN: 351740771 Content-Type: text/plain; charset=us-ascii Organization: NiEstu, Phoenix AZ USA Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-05-09T00:00:00+00:00 List-Id: Okay, I should know better, but I have a mental block here. Someone, please give me a nudge! I'm translating some C++ code to Ada (95). I'm trying to avoid totally redesigning it during the translation, but appropriate changes are fine. The original code has a single .h file, which is included in multiple .cxx files which implement most of the method code. In attempting to follow that structure (which seemed sound enough, and simple enough), I came up with the code pasted below (choppable with gnatchop). This is a GUI package; there's a main "Object" type, from which types like "Button" are derived. There's an "Interface" driver, which calls the drawing routines of the various widgets. I envision user programs having to "with" the main (parent) package and whichever child widget packages they use. My questions are: 1. Isn't there a better way to lay this out in Ada? I'd prefer to avoid one giant package file, but splitting it up seems to cause new problems. 2. In the specific code I've done below, I'm told I can't call abstract subprogram "D" in package P.I's version of "D". What I really want is to dispatch to one of several versions of "D", defined in other child packages such as P.B. That is, when P.I.D is called with a Bt, I want it to call P.B.D. I guess I sorta understand why this isn't working, but what *should* I do here? This really isn't a terribly difficult problem, and I am continuing to work on it, but I'd appreciate suggestions from anyone farther along the Ada OO curve than I. -- Chip ============================================================================== -- p.ads package P is type Ot is tagged null record; type It is new Ot with null record; type OPtr is access all Ot'Class; procedure D (OP: access Ot'Class) is abstract; end P; -- p-i.ads package P.I is procedure D (OP: access It'Class); end P.I; -- p-i.adb with P.B; use P.B; package body P.I is procedure D (OP: access It'Class) is begin D (OPtr (OP)); end D; end P.I; -- p-b.ads package P.B is type Bt is new Ot with null record; procedure D (BP: access Bt'Class); end P.B; -- p-b.adb package body P.B is procedure D (BP: access Bt'Class) is begin null; end D; end P.B; ==============================================================================