comp.lang.ada
 help / color / mirror / Atom feed
From: bn@alsys.com (Brian Nettleton @pulsar)
Subject: Question on Ada.Strings.Unbounded.Slice
Date: 1996/07/15
Date: 1996-07-15T00:00:00+00:00	[thread overview]
Message-ID: <DuLu1I.3I7@thomsoft.com> (raw)


Doesn't look like my original posting went through.  Here's another try
(my apologies if you receive this twice).



While building David Wheeler's "small" program (part of the Lovelace
tutorial) I came across a problem with Ada.Strings.Unbounded.Slice.

I'm getting Index_error when the High > Length(Source) + 1 (where
High, Length and Source are as defined in spec of Ada.Strings.Unbounded).

Here is a smaller program which displays the problem (i.e. this program
raises Ada.Strings.Index_Error):


     with Ada.Strings.Unbounded;
     with Ada.Text_Io;
     procedure Do_Slice is
 
       package TIO renames Ada.Text_Io;
 
     begin
       TIO.Put_Line
         ( Ada.Strings.Unbounded.Slice
           ( Source => ASU.To_Unbounded_String( "hello" ),
             Low    => 1,
             High   => 7 
           ) 
         );
     end Do_Slice;


RM A.4.4:101 states Slice "propagates Index_Error if Low > 
Length(Source) + 1."  But the RM is silent on what happens when
High > Length(Source) + 1!  Is this an oversight in the RM, or
by silence does the RM mean to imply that Index_Error is only
raised when Low exceeds the bounds of the source?  Is it implementation
dependent what happens when High > Length(Source) + 1?

-Brian Nettleton





             reply	other threads:[~1996-07-15  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-07-15  0:00 Brian Nettleton @pulsar [this message]
  -- strict thread matches above, loose matches on Subject: below --
1996-07-11  0:00 Question on Ada.Strings.Unbounded.Slice Brian Nettleton @pulsar
1996-07-16  0:00 ` Keith Thompson
1996-07-21  0:00   ` Robert A Duff
1996-07-25  0:00     ` David Wheeler
replies disabled

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