comp.lang.ada
 help / color / mirror / Atom feed
* re: implicit array subtype conversion
@ 1990-07-27 13:51 
  1990-07-30 18:11 ` Robert I. Eachus
  0 siblings, 1 reply; 2+ messages in thread
From:  @ 1990-07-27 13:51 UTC (permalink / raw)



In my zeal to limit my example and the size of the posting concerning
implict array subtype conversion, I inadvertently changed the nature of my
problem slightly.

I have defined a dynamic length string as follows:

   type STRING_RECORD (Len : NATURAL) is
      record
         S : Standard.STRING(1..Len);
      end record;

   type STRING is access STRING_RECORD;

Then, I declare some variables:

   A : Standard.STRING(7..7);
   B : Standard.STRING(1..1);
   C : STRING;

The following is accepted by the compiler (Verdix Sun 4 Self, version
6.0.2(g)) because of implicit array subtype conversion:

   A := "X";
   B := A;

However, the following is not.  Why?  I don't see the difference in the
assignment of the string because both B and C.S are constrained.

   C := new STRING_RECORD'(Len => A'length, S => A);

--
Terry J. Westley
Arvin/Calspan Advanced Technology Center
P.O. Box 400, Buffalo, NY 14225
acsu.buffalo.edu!planck!hercules!westley

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

* Re: implicit array subtype conversion
  1990-07-27 13:51 implicit array subtype conversion 
@ 1990-07-30 18:11 ` Robert I. Eachus
  0 siblings, 0 replies; 2+ messages in thread
From: Robert I. Eachus @ 1990-07-30 18:11 UTC (permalink / raw)


In article <1990Jul27.135108.11518@planck.uucp> acsu.buffalo.edu!planck!hercules!westley asks:

>  However, the following is not.  Why?  I don't see the difference in the
>  assignment of the string because both B and C.S are constrained.

   This is a language bug, not a compiler bug...  Sliding occurs on
assignment, but not in aggregate component matching.  One of the
"utility" functions I keep around for when this occurs allows me to
say: 
      C := new STRING_RECORD'(Len => A'length, S => Slide(A));

    where slide is defined as:

    function Slide (S: in String; To: in Natural := 1) return String is
      Temp: String(To..To + S'LENGTH - 1) := S;
    begin
      return Temp;
    end Slide;

    silly, but that's the way the language currently works.

Complete question, included for completeness:

   In my zeal to limit my example and the size of the posting concerning
   implict array subtype conversion, I inadvertently changed the nature of my
   problem slightly.

   I have defined a dynamic length string as follows:

      type STRING_RECORD (Len : NATURAL) is
	 record
	    S : Standard.STRING(1..Len);
	 end record;

      type STRING is access STRING_RECORD;

   Then, I declare some variables:

      A : Standard.STRING(7..7);
      B : Standard.STRING(1..1);
      C : STRING;

   The following is accepted by the compiler (Verdix Sun 4 Self, version
   6.0.2(g)) because of implicit array subtype conversion:

      A := "X";
      B := A;

   However, the following is not.  Why?  I don't see the difference in the
   assignment of the string because both B and C.S are constrained.

      C := new STRING_RECORD'(Len => A'length, S => A);
--

					Robert I. Eachus

with STANDARD_DISCLAIMER;
use  STANDARD_DISCLAIMER;
function MESSAGE (TEXT: in CLEVER_IDEAS) return BETTER_IDEAS is...

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

end of thread, other threads:[~1990-07-30 18:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1990-07-27 13:51 implicit array subtype conversion 
1990-07-30 18:11 ` Robert I. Eachus

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