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,56760b0ebeac6ba1 X-Google-Attributes: gid103376,public From: kst@aonix.com (Keith Thompson) Subject: Re: Need of help Leonid(dulman@ibm.net) Date: 1997/02/15 Message-ID: #1/1 X-Deja-AN: 218876328 Sender: news@thomsoft.com (USENET News Admin @flash) X-Nntp-Posting-Host: pulsar References: <5dhbjt$hbe@news.ibm.net.il> <3302387F.16BB@mds.lmco.com> Organization: Aonix, San Diego, CA, USA Newsgroups: comp.lang.ada Originator: kst@pulsar Date: 1997-02-15T00:00:00+00:00 List-Id: In <3302387F.16BB@mds.lmco.com> Rex Reges writes: [...] > An interesting problem occurred while trying to provide the > utility functions. I had the following function: > > function V_String_Of( Standard_String : in String ) > return V_String is > begin > > -- Test omitted for Strings that are too large to fit. > > return ( Size => Standard_String'Length , > S => Standard_String ) ; > > end V_String_Of ; > > > I liked this code because it did not require creating a > temporary variable on the stack, particularly if the string > was very large. However, it failed whenever a substring > was passed which had a starting index other than 1: [...] Try this: function V_String_Of( Standard_String : in String ) return V_String is subtype Constrained_Result is String(1 .. Standard_String'Length); begin -- Test omitted for Strings that are too large to fit. return ( Size => Standard_String'Length , S => Constrained_Result(Standard_String) ); end V_String_Of; Note that the expression for S has to be a conversion, not a qualified expression. -- Keith Thompson (The_Other_Keith) kst@aonix.com <*> TeleSo^H^H^H^H^H^H Alsy^H^H^H^H Thomson Softw^H^H^H^H^H^H^H^H^H^H^H^H^H Aonix 10251 Vista Sorrento Parkway, Suite 300, San Diego, CA, USA, 92121-2706 Antimatter is not a condiment.