comp.lang.ada
 help / color / mirror / Atom feed
From: "bubble" <bubble@bubble.d2g.com>
Subject: Re: dynamic array as return value?
Date: Tue, 19 Oct 2004 13:35:04 +0800
Date: 2004-10-19T13:35:04+08:00	[thread overview]
Message-ID: <cl29jr$j9$1@netnews.hinet.net> (raw)
In-Reply-To: cklea4$9eb$1@netnews.hinet.net

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1206 bytes --]

thank you,all
your answer is very useful..
"bubble" <bubble@bubble.d2g.com> �b�l�� news:cklea4$9eb$1@netnews.hinet.net
�����g...
> according to a book, " Object-oriented Software in Ada 95 Second Edition"
>
> section 8.9 Dynamic Array
>
>
> In Ada the bounds of an array need not be fixed at compile-time, as they
can
> be specified by an object whose
> value is not fixed until run-time. Such an array is known as a dynamic
> array. However, once elaborated, the
> bounds of the dynamic array cannot be changed. Unlike many other
languages,
> Ada allows a dynamic array to be
> returned as the result of a function. For example, a function
Reverse_String
> can be written which reverses
> the characters passed to it.
>
> An implementation of the function Reverse_String is as follows:
>
> function Reverse_String( Str:in String ) return String is
>     Res : String( Str'Range ); --Dynamic bounds
> begin
>     for I in Str'Range loop
>         Res( Str'First+Str'Last-I ) := Str( I );
>     end loop;
>     return Res;
> end Reverse_String;
>
>
> I have a question.
> if ada allow dynamic array can be a return value,it mean bounds array can
be
> return value?
> if can't,why?
>
>





      parent reply	other threads:[~2004-10-19  5:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cklea4$9eb$1@netnews.hinet.net>
2004-10-14 17:24 ` dynamic array as return value? Nick Roberts
2004-10-14 17:28 ` Georg Bauhaus
2004-10-15  3:04 ` Steve
2004-10-15  6:02 ` bubble
2004-10-15 16:36   ` Georg Bauhaus
2004-10-19  5:35 ` bubble [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