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,12a63150f4f961a X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.191.225 with SMTP id hb1mr689693pbc.5.1336192519320; Fri, 04 May 2012 21:35:19 -0700 (PDT) Path: pr3ni5539pbb.0!nntp.google.com!news1.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Shark8 Newsgroups: comp.lang.ada Subject: Re: OOP in Ada: Alternatives for "protected" scope Date: Fri, 4 May 2012 21:33:59 -0700 (PDT) Organization: http://groups.google.com Message-ID: <8966703.3.1336192439923.JavaMail.geo-discussion-forums@ynee1> References: <1vn9nv4aqm9a3.1tqzc91idjlbs$.dlg@40tude.net> NNTP-Posting-Host: 96.2.54.122 Mime-Version: 1.0 X-Trace: posting.google.com 1336192519 5408 127.0.0.1 (5 May 2012 04:35:19 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 5 May 2012 04:35:19 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=96.2.54.122; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-05-04T21:33:59-07:00 List-Id: On Friday, May 4, 2012 1:48:53 PM UTC-5, Felix Krause wrote: >Compared to my version (with redispatching issues fixed), this alternative enforces a weaker contract. It does not enforce the child classes to call Do_Prologue and Do_Epilogue when implementing Do_Something. While this fixes the problem that I cannot have an abstract method in the private part, I think the mix-in solution you suggested in your second post is a better way to handle this. Couldn't you fix this by something like the following: Type Base is tagged null record; Procedure Do_Prolog( Object : in out Base'Class ); Procedure Do_Epilog( Object : in out Base'Class ); -- Both called defined in the body Procedure Work( Object : in out Base ) is abstract; Procedure Do_Work( Object : in out Base'Class ); with a body of: Procedure Do_Work( Object : in out Base'Class ) is begin Object.Do_Prolog; Object.Work; Object.Do_Epilog; end Do_Work; Or am I misunderstanding your intent?