* questions on RM's section of subprograms and dispatching
@ 2018-02-23 20:22 Mehdi Saada
2018-02-23 20:43 ` Simon Wright
0 siblings, 1 reply; 6+ messages in thread
From: Mehdi Saada @ 2018-02-23 20:22 UTC (permalink / raw)
I started reading extensively the RM on subjects that were barely touched by my course, firstly because it stopped at ada95, and it didn't touch concurrent programming either. Sections by sections, I'll ask precisions on important points I couldn't understand, but felt that I should.
package P is
type I is interface;
procedure Op (X : I) is abstract;
end P;
with P;
package Q is
type T is abstract new P.I with private;
-- Op inherited here.
private
type T is abstract new P.I with null record;
procedure Op (X : T) is null;
end Q;
with Q;
package R is
type T2 is new Q.T with null record;
-- Illegal. Op inherited here, but requires overriding.
end R;
-> Is it because T2 is non-abstract and has access only to an abstract view of P ?
___________
Note that it's possible to override a concrete subprogram with an abstract one.
-> It's even compulsory, since a type derived from a tagged type is itself tagged, and tagged types with abstract primitives must be abstract, and can have only abstract primitives.
------------------------
However, if the type is a generic formal type, the sub program need not be overriden for the formal type itself (a nonabstract version will necessarily be provided by the actual type).
-> what does it mean ?? What has it do exactly with
generic
type FOO is abstract tagged private;
function BAR(BORG: in FOO) return FOO;
package PAC is .. end PAC; ?
AI05-0073-1:
...an abstract primitive subprogram shall not be declared in the private part, unless it is overriding an abstract subprogram implicitly declared in the visible part.
-> Why overriding an abstract primitive by another abstract primitive? What can changed, besides aspects, on a subprogram with the same parameters profile ? Also, can parameters subtype of an overriding primitive be widened for use in non-dispatching calls, but so that it wouldn't mess with dispatching calls ?
Others to come ! But not for this section. Had plenty of things too technical, those ones were the only one I felt would impact me or be useful in any way.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: questions on RM's section of subprograms and dispatching
2018-02-23 20:22 questions on RM's section of subprograms and dispatching Mehdi Saada
@ 2018-02-23 20:43 ` Simon Wright
2018-02-23 20:53 ` Mehdi Saada
2018-02-23 20:57 ` Dmitry A. Kazakov
0 siblings, 2 replies; 6+ messages in thread
From: Simon Wright @ 2018-02-23 20:43 UTC (permalink / raw)
Mehdi Saada <00120260a@gmail.com> writes:
> tagged types with abstract primitives must be abstract, and can have
> only abstract primitives
This isn't true; abstract types can have concrete primitives.
See e.g. BC.Containers.Collections
https://sourceforge.net/p/booch95/code/ci/default/tree/src/bc-containers-collections.ads
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: questions on RM's section of subprograms and dispatching
2018-02-23 20:43 ` Simon Wright
@ 2018-02-23 20:53 ` Mehdi Saada
2018-02-23 20:59 ` Mehdi Saada
2018-02-23 20:57 ` Dmitry A. Kazakov
1 sibling, 1 reply; 6+ messages in thread
From: Mehdi Saada @ 2018-02-23 20:53 UTC (permalink / raw)
Okay, I'm lost. Is this explained in Tagged Types and Type Extensions ?
Should I have read before... idiot.
I can see many non-abstract methods with class-wide controlling parameters/results, which is fine... I forgot telling that.
But then there is
function Available (C : Abstract_Collection) return Natural is
pragma Warnings (Off, C);
begin
return Natural'Last;
end Available;
which I don't know what to think of. Is it special in any way ? Or could it have any content, and the body will be inherited the descendants ? I guess it's the second choice. I'll come back tomorrow after reading the section.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: questions on RM's section of subprograms and dispatching
2018-02-23 20:53 ` Mehdi Saada
@ 2018-02-23 20:59 ` Mehdi Saada
2018-02-23 21:55 ` Mehdi Saada
0 siblings, 1 reply; 6+ messages in thread
From: Mehdi Saada @ 2018-02-23 20:59 UTC (permalink / raw)
> Okay, I'm lost. In why section is it explained ?
I can see many non-abstract methods with class-wide controlling parameters/results, which I'm fine... I forgot telling that.
But then there is
function Available (C : Abstract_Collection) return Natural is
pragma Warnings (Off, C);
begin
return Natural'Last;
end Available;
which I don't know what to think of. Is it special in any way ? Or could it have any content, and the body will be inherited the descendants ? I guess it's the second choice. I'll see in Ada distilled and the others ressources before coming back to OOP.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: questions on RM's section of subprograms and dispatching
2018-02-23 20:43 ` Simon Wright
2018-02-23 20:53 ` Mehdi Saada
@ 2018-02-23 20:57 ` Dmitry A. Kazakov
1 sibling, 0 replies; 6+ messages in thread
From: Dmitry A. Kazakov @ 2018-02-23 20:57 UTC (permalink / raw)
On 2018-02-23 21:43, Simon Wright wrote:
> Mehdi Saada <00120260a@gmail.com> writes:
>
>> tagged types with abstract primitives must be abstract, and can have
>> only abstract primitives
>
> This isn't true; abstract types can have concrete primitives.
Yes, only interfaces cannot. Interface is a form of abstract type.
(The limitation is meaningless from the software design POV. In the case
of interfaces it was motivated by compiler implementation concerns.)
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-02-23 21:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-23 20:22 questions on RM's section of subprograms and dispatching Mehdi Saada
2018-02-23 20:43 ` Simon Wright
2018-02-23 20:53 ` Mehdi Saada
2018-02-23 20:59 ` Mehdi Saada
2018-02-23 21:55 ` Mehdi Saada
2018-02-23 20:57 ` Dmitry A. Kazakov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox