comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Experimenting with the OOP features in Ada
Date: Tue, 3 Jan 2017 15:40:35 +0100
Date: 2017-01-03T15:40:35+01:00	[thread overview]
Message-ID: <o4gd54$5qd$1@gioia.aioe.org> (raw)
In-Reply-To: 9f6b6a5a-2f0b-4fbd-8171-36199caa6e49@googlegroups.com

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

      reply	other threads:[~2017-01-03 14:40 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-02 13:21 Experimenting with the OOP features in Ada Laurent
2017-01-02 14:11 ` Brian Drummond
2017-01-02 14:43   ` Brian Drummond
2017-01-02 16:27     ` Laurent
2017-01-03 13:01       ` Brian Drummond
2017-01-03 13:57         ` Laurent
2017-01-03 14:31           ` Dmitry A. Kazakov
2017-01-03 17:07             ` G.B.
2017-01-03 20:42               ` Dmitry A. Kazakov
2017-01-04 12:18             ` Laurent
2017-01-04 12:44               ` Dmitry A. Kazakov
2017-01-05 11:41                 ` Laurent
2017-01-05 13:02                   ` Dmitry A. Kazakov
2017-01-05 13:11                   ` AdaMagica
2017-01-04 15:09               ` Shark8
2017-01-05 11:54                 ` Laurent
     [not found]     ` <85ef59f3-bcbe-4630-9b4d-8285623ab456@googlegroups.com>
2017-01-03 12:48       ` Brian Drummond
2017-01-03 13:43         ` Laurent
2017-01-02 15:54   ` Laurent
2017-01-02 16:41 ` Dmitry A. Kazakov
2017-01-02 18:50   ` Laurent
2017-01-02 20:55     ` Dmitry A. Kazakov
2017-01-03 13:39       ` Laurent
2017-01-03 14:40         ` Dmitry A. Kazakov [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox