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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2e2db8edf2656165 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!feeder1.news.jippii.net!reader1.news.jippii.net!53ab2750!not-for-mail From: Tapio Kelloniemi Subject: Re: Constructing an object References: Newsgroups: comp.lang.ada Message-ID: Date: Sun, 02 Oct 2005 11:52:15 GMT NNTP-Posting-Host: 217.30.176.187 X-Complaints-To: newsmaster@saunalahti.com X-Trace: reader1.news.jippii.net 1128253935 217.30.176.187 (Sun, 02 Oct 2005 14:52:15 EEST) NNTP-Posting-Date: Sun, 02 Oct 2005 14:52:15 EEST Organization: Saunalahti Customer Xref: g2news1.google.com comp.lang.ada:5339 Date: 2005-10-02T11:52:15+00:00 List-Id: Robert A Duff wrote: >Tapio Kelloniemi writes: > >>...If this fails >> and the parent method is not called at run time, Program_Error would >> be raised. I don't think this is a big problem since in most cases missing >> parent method call can be identified like missing return statement. > >The rules about return statements probably should be static: >Every path through the function must have a return statement >or a raise statement. > >Instead, we have: There must be at least one return statement >(never mind that it might be bogus, or might be skipped). >Plus a run-time check. > >The rule you propose about calling the parent could be static, >too: exactly one call on every path (not inside a loop). But the idea of the extended syntax (parent statement or attribute) is to be as useful as possible and I would allow it to be used several times per subprogram and even to call parent versions of other overridden subprograms, even in subprograms not declared to be "extending". Something like: extending procedure Do_A (Object : Parent) is begin Do_Something; end; extending procedure Do_A (Object : Child) is begin Do_Something_Else; Do_A (Object'Parent); end; procedure Do_A_And_B (Object : Child) is begin Do_Something_B; Object'Parent.Do_A; end; -- The above is extending Do_A though it has no relationship to it. -- Therefore the parent call is not required, but useful anyway. -- I'm not very certain about the following idea, but it might be useful -- in some circustances: extending procedure Do_A (Object : Grand_Child) is pragma No_Parent_Call; begin Do_All; -- We have hacked with internal data structures and done the job of -- parents Do_A. Calling the praent's operation could be disastrous. end Do_A; If the type Parent in my example was declared to be private (or tagged private) the parent cal would only be allowed when the type is fully visible, since calling parent's operations when the overridden ones should actually be called can result in bad things. -- Tapio