comp.lang.ada
 help / color / mirror / Atom feed
From: Christoph Grein <christoph.grein@eurocopter.de>
To: comp.lang.ada@ada.eu.org
Subject: Re: Access to strings and string subtypes?
Date: 2000/03/17
Date: 2000-03-21T17:53:19+00:00	[thread overview]
Message-ID: <200003170513.GAA28983@bulgaria.otn.eurocopter.de> (raw)

package Test is

   type Ref is access all String;     <-- unconstrained

   subtype Name is String(1..10);     <-- constrained
   type Name_Ref is access all Name;

   A : aliased Name;                  <-- constrained
   C : aliased String (1..10);        <-- constrained

   D : Name_Ref := A'Access; -- OK
   E : Ref := A'Access; -- Does not statically match designated subtype ???
   F : Ref := C'Access; -- Does not statically match designated subtype ???

   G : Ref := new String'("THIS WORKS"); -- OK!

end Test;

The compiler message ("Does not statically match designated subtype") says
exactly what is wrong:

A pointer to an unconstrained string has to take care of the actual object's 
ranges, a pointer to a constrained string need not.

Thus A'Access and C'Access do not provide range information whereas
   new String'("THIS WORKS")
does.









             reply	other threads:[~2000-03-17  0:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-03-17  0:00 Christoph Grein [this message]
  -- strict thread matches above, loose matches on Subject: below --
2000-03-16  0:00 Access to strings and string subtypes? Steve Folly
2000-03-16  0:00 ` Ehud Lamm
2000-03-16  0:00   ` Steve Folly
2000-03-17  0:00     ` Ehud Lamm
2000-03-17  0:00       ` Steve Folly
2000-03-17  0:00         ` Pascal Obry
2000-03-17  0:00       ` Larry Kilgallen
2000-03-17  0:00         ` Robert Dewar
2000-03-17  0:00           ` Robert A Duff
2000-03-18  0:00             ` Robert Dewar
2000-03-20  0:00               ` Tucker Taft
replies disabled

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