comp.lang.ada
 help / color / mirror / Atom feed
From: kst@aonix.com (Keith Thompson)
Subject: Re: Need of help Leonid(dulman@ibm.net)
Date: 1997/02/15
Date: 1997-02-15T00:00:00+00:00	[thread overview]
Message-ID: <E5MBIp.Ix0@thomsoft.com> (raw)
In-Reply-To: 3302387F.16BB@mds.lmco.com


In <3302387F.16BB@mds.lmco.com> Rex Reges <reges@mds.lmco.com> 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 <http://www.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.




  reply	other threads:[~1997-02-15  0:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-02-08  0:00 Need of help Leonid(dulman@ibm.net) dulman
1997-02-08  0:00 ` Robert Dewar
1997-02-10  0:00   ` Thomas Hoffmann
1997-02-10  0:00     ` Robert Dewar
     [not found]       ` <5dpftl$qi@fozzie.sun3.iaf.nl>
1997-02-12  0:00         ` Robert Dewar
1997-02-13  0:00           ` Keith Thompson
1997-02-12  0:00     ` Rex Reges
1997-02-15  0:00       ` Keith Thompson [this message]
1997-02-17  0:00         ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox