comp.lang.ada
 help / color / mirror / Atom feed
* about inheritance of subtypes and entities (such as constants) related to a type in the same package
@ 2018-05-26 16:14 Mehdi Saada
  2018-05-26 16:44 ` Mehdi Saada
  2018-05-29 22:12 ` Randy Brukardt
  0 siblings, 2 replies; 28+ messages in thread
From: Mehdi Saada @ 2018-05-26 16:14 UTC (permalink / raw)


Hello. In my reading of Barnes' book I learn many little details that aren't apparent in the rm... no surprise.
Being used to much readability, I'm surprised, however, by the situation with inheritance:

with Ada.Text_IO;
package AA is
   type A is private;
   subtype B is A;
   function IS_IN_B(obj: A) return boolean;
   procedure TEst_B (Obj_B: B) is Null;
private
   type A is new Integer;
end AA;

So if I derive a new type from A in another package, it would inherit IS_IN, but not the declaration of B ? This declaration would become anonymous and I would have to means to get, say, B'range or whatever attributes it has ("private" was for convenience), but to look in package AA from where A comes ?
Also, no being able to do things like "pragma Assert (Obj in <new_anonymous_subtype>);" seems pretty lame. Or did I misunderstood something ?

It could have been decided that subtypes of a type declared in the same package, are inherited as would be subprograms. Same goes for constants. Which subtype B is mentioned (from A or C) would be resolved at least at compile time. Having the same name isn't that good, but that's secondary.

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2018-06-01 15:27 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-26 16:14 about inheritance of subtypes and entities (such as constants) related to a type in the same package Mehdi Saada
2018-05-26 16:44 ` Mehdi Saada
2018-05-29 22:07   ` Randy Brukardt
2018-05-29 22:12 ` Randy Brukardt
2018-05-30  8:13   ` Dmitry A. Kazakov
2018-05-30 19:25     ` Randy Brukardt
2018-05-30 19:45       ` Dmitry A. Kazakov
2018-05-30 19:59         ` Randy Brukardt
2018-05-31  8:44           ` Dmitry A. Kazakov
2018-05-31 22:48             ` Randy Brukardt
2018-05-31 23:39               ` Mehdi Saada
2018-06-01  2:50                 ` Shark8
2018-06-01  7:35                 ` Dmitry A. Kazakov
2018-05-30 20:53   ` Dan'l Miller
2018-05-31  8:54     ` Dmitry A. Kazakov
2018-05-31 14:29       ` Dan'l Miller
2018-05-31 14:38         ` Dan'l Miller
2018-05-31 17:37         ` Dmitry A. Kazakov
2018-05-31 18:53           ` Dan'l Miller
2018-05-31 19:59             ` Dmitry A. Kazakov
2018-05-31 21:10               ` Dan'l Miller
2018-06-01  7:56                 ` Dmitry A. Kazakov
2018-06-01 14:01                   ` Dan'l Miller
2018-06-01 15:27                     ` Dmitry A. Kazakov
2018-05-31 22:45             ` Randy Brukardt
2018-05-31 23:50               ` Dan'l Miller
2018-06-01  7:38               ` Dmitry A. Kazakov
2018-05-31 22:34     ` Randy Brukardt

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