comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: "&" for array versus "&" for Strings
Date: Wed, 9 Oct 2002 12:43:42 GMT
Date: 2002-10-09T12:43:42+00:00	[thread overview]
Message-ID: <wccelaz3hq9.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: mailman.1034141702.27775.comp.lang.ada@ada.eu.org

"Grein, Christoph" <christoph.grein@eurocopter.com> writes:

> procedure Array_Test is
> 
>   type Name_Array is array (Positive range <>) of String (1..6);
> 
>   procedure Print_Names (Names : Name_Array) is separate;
> 
> begin
> 
>   Print_Names ("Ada   " & "Babbel");
>   Print_Names (string'("Ada   ") & string'("Babbel"));
> 
> end Array_Test;
> 
> > It seems to me that the "&" should resolve to the
> > (string, string)-->Name_Array one, even without the "String'(...)"
> > qualifications.  Apparently, the older compiler resolved it to the wrong
> > one, and the newer one can't resolve it (which is an improvement, but
> > still a bug).
> > 
> > I'm not surprised that such a bug has never been noticed before.  Most
> > people don't write code that uses "&" to concatenate two Strings to
> > produce something other than String!  First, it's confusing (to humans,
> > I mean, in addition to compilers).  Second, it requires fixed-length
> > strings, which is almost never what you want in an array.
> 
> I think only the first statement is ambiguous since the compiler is not allowed 
> to lookk inside the aggregate to see what is is, a string or an array of 
> strings.

There is no aggregate in this example.

There are two string_literals, and RM-4.2(4) says "...single string
type".  So I think this one should resolve OK.

> With the second statment, it's clear the aggregates are strings, so it can 
> resolve the "&" operator to the correct one returning Name_Array. The one 
> returning String is out because Print_Names does not accept String.

- Bob



  reply	other threads:[~2002-10-09 12:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-09  5:28 "&" for array versus "&" for Strings Grein, Christoph
2002-10-09 12:43 ` Robert A Duff [this message]
2002-10-09 17:38   ` Steven Deller
2002-10-09 19:46     ` Robert A Duff
  -- strict thread matches above, loose matches on Subject: below --
2002-10-10  6:28 Grein, Christoph
2002-10-10  7:15 ` Preben Randhol
2002-10-10  4:35 Grein, Christoph
2002-10-10  6:06 ` Preben Randhol
2002-10-09  9:59 Grein, Christoph
     [not found] <200210081153.NAA17399@bulgaria.otn.eurocopter.de>
2002-10-08 12:21 ` David C. Hoos, Sr.
2002-10-08 13:56   ` Sergey Koshcheyev
2002-10-08 15:46     ` David C. Hoos
2002-10-08 15:56       ` Preben Randhol
2002-10-08 11:53 Grein, Christoph
2002-10-08 13:46 ` Preben Randhol
2002-10-08 13:49 ` Preben Randhol
2002-10-08 16:41 ` Robert A Duff
2002-10-09  9:35   ` Preben Randhol
2002-10-08 10:57 Preben Randhol
2002-10-14 16:34 ` Eric G. Miller
2002-10-14 17:54   ` Robert A Duff
replies disabled

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