comp.lang.ada
 help / color / mirror / Atom feed
* Slicing & sliding
@ 1999-04-23  0:00 John B. Mattehws, M.D.
  1999-04-23  0:00 ` Tucker Taft
  0 siblings, 1 reply; 3+ messages in thread
From: John B. Mattehws, M.D. @ 1999-04-23  0:00 UTC (permalink / raw)



Given the following program

with Text_IO;

procedure Slice is

S : String (1 .. 64) := (others => '.');

    function F return String is
    begin
        return "result";
    end F;

begin

    Text_IO.Put_Line(S);
    S(S'Range) := F(S'Range);
    Text_IO.Put_Line(S);
    
end Slice;

The output is
................................................................
result

I was suprised to see that the indicated slice of F (F(S'Range)) is allowed
to be larger than the result returned by F, despite RM 4.1.2(7). For
smaller slices, the remainder of S seems to slide down, and the rest is
padded with nulls. Can someone help me understand this? Is this conformant
with the RM?

Thanks,

John
----
John B. Matthews, M.D.
matthewsj@saic.com; jmattthews@nova.wright.edu




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Slicing & sliding
  1999-04-23  0:00 Slicing & sliding John B. Mattehws, M.D.
@ 1999-04-23  0:00 ` Tucker Taft
  1999-04-25  0:00   ` John B. Matthews, M.D.
  0 siblings, 1 reply; 3+ messages in thread
From: Tucker Taft @ 1999-04-23  0:00 UTC (permalink / raw)


John B. Mattehws, M.D. wrote:
> 
> Given the following program
> 
> with Text_IO;
> 
> procedure Slice is
> 
> S : String (1 .. 64) := (others => '.');
> 
>     function F return String is
>     begin
>         return "result";
>     end F;
> 
> begin
> 
>     Text_IO.Put_Line(S);
>     S(S'Range) := F(S'Range);
>     Text_IO.Put_Line(S);
> 
> end Slice;
> 
> The output is
> ................................................................
> result
> 
> I was suprised to see that the indicated slice of F (F(S'Range)) is allowed
> to be larger than the result returned by F, despite RM 4.1.2(7). For
> smaller slices, the remainder of S seems to slide down, and the rest is
> padded with nulls. Can someone help me understand this? Is this conformant
> with the RM?

Sure looks like a compiler bug to me.  Alternatively, you
are suppressing constraint checks without knowing it.
On my favorite compiler, your program prints the line of dots, and
then dies with an unhandled Constraint_Error on the slice
assignment.

> Thanks,
> 
> John
> ----
> John B. Matthews, M.D.
> matthewsj@saic.com; jmattthews@nova.wright.edu

-- 
-Tucker Taft   stt@averstar.com   http://www.averstar.com/~stt/
Technical Director, Distributed IT Solutions  (www.averstar.com/tools)
AverStar (formerly Intermetrics, Inc.)   Burlington, MA  USA




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Slicing & sliding
  1999-04-23  0:00 ` Tucker Taft
@ 1999-04-25  0:00   ` John B. Matthews, M.D.
  0 siblings, 0 replies; 3+ messages in thread
From: John B. Matthews, M.D. @ 1999-04-25  0:00 UTC (permalink / raw)


In article <3720EA2F.B359672@averstar.com>, Tucker Taft <stt@averstar.com>
wrote:

> John B. Mattehws, M.D. wrote:
> > 
> > Given the following program
> > 
> > with Text_IO;
> > 
> > procedure Slice is
> > 
> > S : String (1 .. 64) := (others => '.');
> > 
> >     function F return String is
> >     begin
> >         return "result";
> >     end F;
> > 
> > begin
> > 
> >     Text_IO.Put_Line(S);
> >     S(S'Range) := F(S'Range);
> >     Text_IO.Put_Line(S);
> > 
> > end Slice;
> > 
> > The output is
> > ................................................................
> > result
> > 
> > I was suprised to see that the indicated slice of F (F(S'Range)) is allowed
> > to be larger than the result returned by F, despite RM 4.1.2(7). For
> > smaller slices, the remainder of S seems to slide down, and the rest is
> > padded with nulls. Can someone help me understand this? Is this conformant
> > with the RM?
> 
> Sure looks like a compiler bug to me.  Alternatively, you
> are suppressing constraint checks without knowing it.

The latter, of course. Now clear in restrospect:-)

Thanks,

John

> On my favorite compiler, your program prints the line of dots, and
> then dies with an unhandled Constraint_Error on the slice
> assignment.
> 
> > Thanks,
> > 
> > John
> > ----
> > John B. Matthews, M.D.
> > matthewsj@saic.com; jmattthews@nova.wright.edu
> 
> -- 
> -Tucker Taft   stt@averstar.com   http://www.averstar.com/~stt/
> Technical Director, Distributed IT Solutions  (www.averstar.com/tools)
> AverStar (formerly Intermetrics, Inc.)   Burlington, MA  USA




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-04-25  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-04-23  0:00 Slicing & sliding John B. Mattehws, M.D.
1999-04-23  0:00 ` Tucker Taft
1999-04-25  0:00   ` John B. Matthews, M.D.

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