subtype String_80 is String(1.. 80); function makeSpaceString return String is spaceStr:String_80 := (others => ' '); begin return spaceStr; --can I do it? end makeSpaceString; function makeSpaceString(length:Natural) return String is spaceStr :string(1..length) := (others => ' '); begin return spaceStr; --- ??? end makeSpaceString; Hi dear: Thank your answer. my question is about memory allocation in ada95. I remember,local variable memory allocate should use stack not heap memory. In above 2 functions. the variable spaceStr are local variable in function,right? after execute end of function,data in stack memory should free to system. it mean I return a data in stack and it is free,it will occure illegal access? I don't understand why "dynamic array" can be return? "bubble" �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? > >