From: "Jean-Pierre Rosen" <rosen@adalog.fr>
Subject: Re: Array type conversion
Date: Fri, 18 Oct 2002 08:55:16 +0200
Date: 2002-10-18T08:55:16+02:00 [thread overview]
Message-ID: <aoobn7$kn0$1@s1.read.news.oleane.net> (raw)
In-Reply-To: aoo3h9$s7u$1@news.chatlink.com
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1177 bytes --]
"Keith" <nono@joimail.net> a �crit dans le message news:
aoo3h9$s7u$1@news.chatlink.com...
> What is the implementation consequence of not following Ada reference
> manual section 4.6 12/1 "The component subtypes shall statically match"?
>
> What was the rational behind not allowing something like the following:
>
> type some_type is new integer;
> type A is array ( index_type) of integer;
> type B is array ( index_type) of some_type;
> Array_A:A;
> Array_B:B;
>
>
> declare
>
> begin
> Array_A:=A( Array_B);
>
> end;
>
> Rather than the legal but more cumbersome
>
> for Index in index_type'range loop
> Array_A(Index):=A(Array_B(Index));
> end loop;
>
A derived type needs not have the same representation as its ancestor type.
If the subtypes statically match, the compiler can perform a simple memory
copy. Otherwise, the compiler must in effect generate the exact equivalent
of the loop you give, and there is a deliberate decision in Ada to avoid, as
far as possible, *hidden* inefficiencies.
--
---------------------------------------------------------
J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr
next prev parent reply other threads:[~2002-10-18 6:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-18 4:43 Array type conversion Keith
2002-10-18 6:55 ` Jean-Pierre Rosen [this message]
2002-10-18 15:15 ` Robert A Duff
2002-10-19 3:27 ` Keith
2002-10-18 14:59 ` Robert A Duff
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox