From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5c1c45943bf6a5bc X-Google-Attributes: gid103376,public From: Dale Stanbrough Subject: Re: 'first of strings returned from a function should be 1? Date: 1997/07/27 Message-ID: <5rfcs1$i3j$1@goanna.cs.rmit.edu.au>#1/1 X-Deja-AN: 259379884 Distribution: world References: <5rcaqi$le8$1@goanna.cs.rmit.edu.au> <01bc9a76$459c2250$4c8371a5@dhoossr> X-XXMessage-ID: Organization: Royal Melbourne Institute of Technology Newsgroups: comp.lang.ada Date: 1997-07-27T00:00:00+00:00 List-Id: David C. Hoos writes: "What's wrong with Result_String (Result_String'first) for getting at the first character of a function result?" Because i wanted to call the function, store the first character and not declare a local string. I am guessing that a local string would require extra copying (which i generally try to design out of programs) from heap to stack, although this may not be the case. "From my own experience, I know that it is easy to write a poor function returning a string result of which the first subscript is not 1, and I always make the effort to slice (if necessary) the result into the range 1 . result'length, but if you're using something you can't change, then something like New_Result (1 .. Result_String'length) := Result_String(Result_String'first .. result_String'first + Result_String'length -1) will do the job." Yes, this will work, but it also requires copying. The subtype solution seems better to me. thanks anyway. Dale