comp.lang.ada
 help / color / mirror / Atom feed
* Strings initialised by literals
@ 2001-07-21 18:58 Matthew Woodcraft
  2001-07-22  0:52 ` James Rogers
  0 siblings, 1 reply; 5+ messages in thread
From: Matthew Woodcraft @ 2001-07-21 18:58 UTC (permalink / raw)



I've a feeling this question came across this newsgroup recently, but
I've been unable to find the thread.

If I write

      Sample : String := "example";

Gnat tells me that Sample'First is 1. Is this guaranteed by the
langauge, or does the compiler choose?

-M-



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

* Re: Strings initialised by literals
  2001-07-21 18:58 Strings initialised by literals Matthew Woodcraft
@ 2001-07-22  0:52 ` James Rogers
  2001-07-23  1:30   ` Tucker Taft
  0 siblings, 1 reply; 5+ messages in thread
From: James Rogers @ 2001-07-22  0:52 UTC (permalink / raw)


This is guaranteed by the language.

The string type is defined as :

type string is array(Positive range <>) of character;

Jim Rogers
Colorado Springs, Colorado

Matthew Woodcraft wrote:
> 
> I've a feeling this question came across this newsgroup recently, but
> I've been unable to find the thread.
> 
> If I write
> 
>       Sample : String := "example";
> 
> Gnat tells me that Sample'First is 1. Is this guaranteed by the
> langauge, or does the compiler choose?
> 
> -M-



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

* Re: Strings initialised by literals
  2001-07-22  0:52 ` James Rogers
@ 2001-07-23  1:30   ` Tucker Taft
  2001-07-23  2:45     ` James Rogers
  2001-07-23 10:55     ` Larry Kilgallen
  0 siblings, 2 replies; 5+ messages in thread
From: Tucker Taft @ 2001-07-23  1:30 UTC (permalink / raw)




James Rogers wrote:

> This is guaranteed by the language.
>
> The string type is defined as :
>
> type string is array(Positive range <>) of character;

Not all strings start at 1.  However, when there is no "applicable index
constraint" provide by context, then the low bound is the lower bound of
the index subtype, which in this case is Positive (and Positive'First =
1).
See RM95 4.3(26).

> Jim Rogers
> Colorado Springs, Colorado
>
> Matthew Woodcraft wrote:
> >
> > I've a feeling this question came across this newsgroup recently, but
> > I've been unable to find the thread.
> >
> > If I write
> >
> >       Sample : String := "example";
> >
> > Gnat tells me that Sample'First is 1. Is this guaranteed by the
> > langauge, or does the compiler choose?
> >
> > -M-

-Tucker Taft  stt@avercom.net




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

* Re: Strings initialised by literals
  2001-07-23  1:30   ` Tucker Taft
@ 2001-07-23  2:45     ` James Rogers
  2001-07-23 10:55     ` Larry Kilgallen
  1 sibling, 0 replies; 5+ messages in thread
From: James Rogers @ 2001-07-23  2:45 UTC (permalink / raw)


I agree completely. However, the specific question asked about the
lower bound for a string literal. This should fall into the no
"applicable index constraint" exception you mentioned below.
For that reason I said the lower bound will be 1.

Jim Rogers
Colorado Springs, Colorado USA

Tucker Taft wrote:
> 
> James Rogers wrote:
> 
> > This is guaranteed by the language.
> >
> > The string type is defined as :
> >
> > type string is array(Positive range <>) of character;
> 
> Not all strings start at 1.  However, when there is no "applicable index
> constraint" provide by context, then the low bound is the lower bound of
> the index subtype, which in this case is Positive (and Positive'First =
> 1).
> See RM95 4.3(26).
> 
> > Jim Rogers
> > Colorado Springs, Colorado
> >
> > Matthew Woodcraft wrote:
> > >
> > > I've a feeling this question came across this newsgroup recently, but
> > > I've been unable to find the thread.
> > >
> > > If I write
> > >
> > >       Sample : String := "example";
> > >
> > > Gnat tells me that Sample'First is 1. Is this guaranteed by the
> > > langauge, or does the compiler choose?
> > >
> > > -M-
> 
> -Tucker Taft  stt@avercom.net



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

* Re: Strings initialised by literals
  2001-07-23  1:30   ` Tucker Taft
  2001-07-23  2:45     ` James Rogers
@ 2001-07-23 10:55     ` Larry Kilgallen
  1 sibling, 0 replies; 5+ messages in thread
From: Larry Kilgallen @ 2001-07-23 10:55 UTC (permalink / raw)


In article <3B5B7E39.79B814F4@avercom.net>, Tucker Taft <stt@avercom.net> writes:
> 
> 
> James Rogers wrote:
> 
>> This is guaranteed by the language.
>>
>> The string type is defined as :
>>
>> type string is array(Positive range <>) of character;
> 
> Not all strings start at 1.  However, when there is no "applicable index
> constraint" provide by context, then the low bound is the lower bound of
> the index subtype, which in this case is Positive (and Positive'First =
> 1).
> See RM95 4.3(26).

Actually 4.3.3(26), I presume (now that you have pointed it out).



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

end of thread, other threads:[~2001-07-23 10:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-21 18:58 Strings initialised by literals Matthew Woodcraft
2001-07-22  0:52 ` James Rogers
2001-07-23  1:30   ` Tucker Taft
2001-07-23  2:45     ` James Rogers
2001-07-23 10:55     ` Larry Kilgallen

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