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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,dbcfe2b0a74da57e,start X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!g4g2000hsf.googlegroups.com!not-for-mail From: shaunpatterson@gmail.com Newsgroups: comp.lang.ada Subject: Inherited Methods and such Date: Mon, 17 Sep 2007 07:26:06 -0700 Organization: http://groups.google.com Message-ID: <1190039166.449906.15070@g4g2000hsf.googlegroups.com> NNTP-Posting-Host: 155.219.241.10 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1190039166 30944 127.0.0.1 (17 Sep 2007 14:26:06 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 17 Sep 2007 14:26:06 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 3.0.04506.30; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: g4g2000hsf.googlegroups.com; posting-host=155.219.241.10; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Xref: g2news2.google.com comp.lang.ada:1983 Date: 2007-09-17T07:26:06-07:00 List-Id: Hi, I'm trying to get sub-packages to override superclass methods. Specifically, I'm trying to implement a Template Design pattern in Ada. I want a function in the base package that calls two methods and some other code. Something like: --- BASE CLASS --- package body Base is procedure Load is begin go; end Load; procedure Test1 is begin Put_Line ("Test1 FROM BASE CLASS"); end Test1; procedure Test2 is begin Put_Line ("Test2 FROM BASE CLASS"); end Test2; procedure Do is begin Test1; Put_Line ("Doing something"); Test2; end Do; end Base; --------- then in the sub classes, I'd like to over ride Test1 and 2 into something like: package Base.SubclassA is procedure Test1 is begin Put_Line ("Test1 FROM SUBCLASS A"); end Test1; procedure Test2 is begin Put_Line ("Test2 FROM SUBCLASS A"); end Test2; end Base.SubclassA; --------------------- Now I'd like to call it something like: if UsingBaseClass then Base.go; else Base.SubclassA.go; end if; -------------------- If the baseclass test passes, I'd like the output: Test1 FROM BASE CLASS doing something Test2 FROM BASE CLASS else Test1 FROM SUBCLASSA doing something Test2 FROM SUBCLASSA Is this type of method inheritance supported in ada? If so, where am I going wrong? Thanks -- Shaun Patterson