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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Experimenting with the OOP features in Ada Date: Tue, 3 Jan 2017 15:40:35 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <29380aa7-0c3b-4908-94c6-aa91f3996b42@googlegroups.com> <1c754dc2-01fc-455a-bd9a-01ecb71591af@googlegroups.com> <9f6b6a5a-2f0b-4fbd-8171-36199caa6e49@googlegroups.com> NNTP-Posting-Host: s3c6wwRqkurrfTZpuYYZ+w.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:33022 Date: 2017-01-03T15:40:35+01:00 List-Id: On 2017-01-03 14:39, Laurent wrote: > On Monday, 2 January 2017 21:55:49 UTC+1, Dmitry A. Kazakov wrote: >> The keyword hints the compiler that the subprogram overrides the >> parent's implementation. If you make a mistake in the parameter profile, >> the compiler will reject the program. It adds a lot of safety. If not >> keeping it Ada 95 compatible, always use "overriding" and "not >> overriding" when declaring operations on tagged types. It is a good style. >> > But I have to put it for every function/procedure. > It won't work if I just put it at the first possible place and expect that the > compiler will automagically figure out where to apply it. That is the idea. The compiler already knows if that is overriding or not. You tell it that your intention was to override. It is a fully redundant declaration meant to add safety. To put it in other words, if your program compiles you could remove all appearances of "overriding" and "not overriding" and it would still compile. [The reverse is wrong, as your attempt below illustrated] >>> Gnat was only complaining that Create_Name needs overriding even if >>> Create_Code_SIL is also in the Base_Type which is abstract. >>>> >> This a different story. Here the compiler complains that you forgot to >> override an operation that must be overridden. Overriding is required >> for abstract operations and operations returning new objects. In the >> first case there is no implementation to inherit from. In the second >> case the implementation would be most likely garbage. >> >> > After changing the functions to procedures gnat complains that Set_Code_SIL > doesn't override. Before the change it didn't even it should have done so? Because it is not overriding. Then you declare it as "not overriding". Always tell the compiler the truth. (:-)) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de