comp.lang.ada
 help / color / mirror / Atom feed
* Question on Ada 9X vs Ada 83.
@ 1993-09-22 14:04 cis.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!spool.mu.ed
  0 siblings, 0 replies; 2+ messages in thread
From: cis.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!spool.mu.ed @ 1993-09-22 14:04 UTC (permalink / raw)


I have a question about a compability issue and wonder if anyone on the
net
knows the answer or knows whom I could direct my question.

The issue is "Derived type inherits all operations of Parent".

An example is

  package P is
    type Some_Array is array (1 .. 10) of Integer;
    function "&" (Left, Right: Some_Array) return Some_Array;
    type New_Array is new Some_Array;
  end P;

I understand that in Ada 9X, New_Array inherits "&" from Some_Array and
that does not happen in Ada 83.

The my questions are:
  1 - Would this happen if these declarations were in a procedure body?
  2 - If the function declaration was moved after the type declaration
for
      New_Array would New_Array still inherit the "&" function from 
      Some_Array?

I have tried to figure this out by reading the Ada 9X RM but it was not
very clear to me.

Brian Hanson

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

* Re: Question on Ada 9X vs Ada 83.
@ 1993-09-23 21:54 Tucker Taft
  0 siblings, 0 replies; 2+ messages in thread
From: Tucker Taft @ 1993-09-23 21:54 UTC (permalink / raw)


In article <CDrDrJ.4px@News.MR.Net> info@xinotech.com (Brian Hanson) writes:

>I have a question about a compability issue and wonder if anyone on the
>net
>knows the answer or knows whom I could direct my question.
>
>The issue is "Derived type inherits all operations of Parent".
>
>An example is
>
>  package P is
>    type Some_Array is array (1 .. 10) of Integer;
>    function "&" (Left, Right: Some_Array) return Some_Array;
>    type New_Array is new Some_Array;
>  end P;
>
>I understand that in Ada 9X, New_Array inherits "&" from Some_Array and
>that does not happen in Ada 83.
>
>The my questions are:
>  1 - Would this happen if these declarations were in a procedure body?

Yes.  When a primitive operation is overridden, the overriding operation
becomes primitive as well, and is hence available for being inherited
on (subsequent) derivation (see RM9X-3.2.3(2);3.0/4.0 last sentence).

>  2 - If the function declaration was moved after the type declaration
>for
>      New_Array would New_Array still inherit the "&" function from 
>      Some_Array?

No, a type only inherits primitive operations that are visible
at the point of the derivation (RM9X-3.4(16);3.0/4.0).  So New_Array
would inherit the predefined "&" instead of the user-defined one
if the user-defined "&" were declared after the point of derivation.

>I have tried to figure this out by reading the Ada 9X RM but it was not
>very clear to me.

I hope the above citations help.

>Brian Hanson

S. Tucker Taft    stt@inmet.com
Ada 9X Mapping/Revision Team
Intermetrics, Inc.
Cambridge, MA  02138

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

end of thread, other threads:[~1993-09-23 21:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1993-09-23 21:54 Question on Ada 9X vs Ada 83 Tucker Taft
  -- strict thread matches above, loose matches on Subject: below --
1993-09-22 14:04 cis.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!spool.mu.ed

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